Scroll to bottom

pull/182/head
M66B 5 years ago
parent 3f98b9ee97
commit 3754cf966c

@ -5170,8 +5170,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override @Override
public void onCurrentListChanged(@Nullable PagedList<TupleMessageEx> previousList, @Nullable PagedList<TupleMessageEx> currentList) { public void onCurrentListChanged(@Nullable PagedList<TupleMessageEx> previousList, @Nullable PagedList<TupleMessageEx> currentList) {
if (gotoTop && previousList != null) { if (gotoTop && previousList != null) {
gotoTop = false; if (ascending) {
properties.scrollTo(0, 0); if (currentList != null && currentList.size() > 0) {
properties.scrollTo(currentList.size() - 1, 0);
if (currentList.get(currentList.size() - 1) != null)
gotoTop = false;
}
} else {
gotoTop = false;
properties.scrollTo(0, 0);
}
} }
if (selectionTracker != null && selectionTracker.hasSelection()) { if (selectionTracker != null && selectionTracker.hasSelection()) {
@ -5255,7 +5263,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
void gotoTop() { void gotoTop() {
properties.scrollTo(0, 0); if (ascending) {
PagedList<TupleMessageEx> list = getCurrentList();
if (list != null && list.size() > 0)
properties.scrollTo(list.size() - 1, 0);
} else
properties.scrollTo(0, 0);
this.gotoTop = true; this.gotoTop = true;
} }

@ -1478,6 +1478,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return false; return false;
} }
@Override
public void setExpanded(TupleMessageEx message, boolean value) { public void setExpanded(TupleMessageEx message, boolean value) {
// Prevent flicker // Prevent flicker
if (value && if (value &&
@ -1539,6 +1540,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return heights.get(id, defaultHeight); return heights.get(id, defaultHeight);
} }
@Override
public void setPosition(long id, Pair<Integer, Integer> position) { public void setPosition(long id, Pair<Integer, Integer> position) {
if (position == null) if (position == null)
positions.remove(id); positions.remove(id);
@ -1546,6 +1548,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
positions.put(id, position); positions.put(id, position);
} }
@Override
public Pair<Integer, Integer> getPosition(long id) { public Pair<Integer, Integer> getPosition(long id) {
return positions.get(id); return positions.get(id);
} }
@ -1564,6 +1567,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
} }
@Override
public void scrollTo(final int pos, final int y) { public void scrollTo(final int pos, final int y) {
new Handler().post(new Runnable() { new Handler().post(new Runnable() {
@Override @Override

Loading…
Cancel
Save