diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index ebc87aeddc..4bd0709ee2 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -157,7 +157,7 @@ public class AdapterMessage extends RecyclerView.Adapter differ; private SelectionTracker selectionTracker = null; @@ -3065,16 +3065,20 @@ public class AdapterMessage extends RecyclerView.Adapter() { @Override public void onCurrentListChanged(@Nullable PagedList previousList, @Nullable PagedList currentList) { - if (gotop) { - gotop = false; + if (gotoTop) { + gotoTop = false; properties.scrollTo(0); } } }); } - void submitList(PagedList list, boolean gotop) { - this.gotop = gotop; + void gotoTop() { + properties.scrollTo(0); + this.gotoTop = true; + } + + void submitList(PagedList list) { differ.submitList(list); } diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index e782c40e86..3693af8d5f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -2612,6 +2612,9 @@ public class FragmentMessages extends FragmentBase { private boolean loading = false; private void loadMessagesNext(final boolean top) { + if (top) + adapter.gotoTop(); + ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class); LiveData> liveMessages = model.getPagedList( @@ -2651,8 +2654,6 @@ public class FragmentMessages extends FragmentBase { }); liveMessages.observe(getViewLifecycleOwner(), new Observer>() { - private boolean topped = false; - @Override public void onChanged(@Nullable PagedList messages) { if (messages == null) @@ -2662,10 +2663,8 @@ public class FragmentMessages extends FragmentBase { if (handleThreadActions(messages)) return; - boolean gotop = (top && !topped); - topped = true; - Log.i("Submit messages=" + messages.size() + " top=" + gotop); - adapter.submitList(messages, gotop); + Log.i("Submit messages=" + messages.size()); + adapter.submitList(messages); // This is to workaround not drawing when the search is expanded new Handler().post(new Runnable() {