mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 08:29:24 +00:00
Attempt to keep scroll position on rotating
This commit is contained in:
parent
2c88095ea3
commit
4394843878
2 changed files with 17 additions and 0 deletions
|
@ -264,6 +264,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private static boolean debug;
|
||||
|
||||
private boolean gotoTop = false;
|
||||
private Integer gotoPos = null;
|
||||
private boolean firstClick = false;
|
||||
private int searchResult = 0;
|
||||
private AsyncPagedListDiffer<TupleMessageEx> differ;
|
||||
|
@ -5441,6 +5442,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
}
|
||||
|
||||
if (gotoPos != null && currentList != null && currentList.size() > 0) {
|
||||
properties.scrollTo(gotoPos, 0);
|
||||
gotoPos = null;
|
||||
}
|
||||
|
||||
if (selectionTracker != null && selectionTracker.hasSelection()) {
|
||||
Selection<Long> selection = selectionTracker.getSelection();
|
||||
|
||||
|
@ -5530,6 +5536,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.gotoTop = true;
|
||||
}
|
||||
|
||||
void gotoPos(int pos) {
|
||||
if (pos != RecyclerView.NO_POSITION)
|
||||
gotoPos = pos;
|
||||
}
|
||||
|
||||
void submitList(PagedList<TupleMessageEx> list) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TupleMessageEx message = list.get(i);
|
||||
|
|
|
@ -300,6 +300,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
private SelectionPredicateMessage selectionPredicate = null;
|
||||
private SelectionTracker<Long> selectionTracker = null;
|
||||
|
||||
private Integer scroll = null;
|
||||
private Long prev = null;
|
||||
private Long next = null;
|
||||
private Long closeId = null;
|
||||
|
@ -3373,6 +3374,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
if (rvMessage != null) {
|
||||
Parcelable rv = rvMessage.getLayoutManager().onSaveInstanceState();
|
||||
outState.putParcelable("fair:rv", rv);
|
||||
|
||||
LinearLayoutManager llm = (LinearLayoutManager) rvMessage.getLayoutManager();
|
||||
outState.putInt("fair:scroll", llm.findFirstVisibleItemPosition());
|
||||
}
|
||||
|
||||
if (selectionTracker != null)
|
||||
|
@ -3402,6 +3406,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
rvMessage.getLayoutManager().onRestoreInstanceState(rv);
|
||||
}
|
||||
|
||||
adapter.gotoPos(savedInstanceState.getInt("fair:scroll"));
|
||||
|
||||
if (selectionTracker != null)
|
||||
selectionTracker.onRestoreInstanceState(savedInstanceState);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue