Save recyclerview state

This commit is contained in:
M66B 2019-02-10 21:50:47 +00:00
parent d08c9b34bb
commit 38352c1760
1 changed files with 10 additions and 0 deletions

View File

@ -1437,6 +1437,11 @@ public class FragmentMessages extends FragmentBase {
for (String name : values.keySet()) for (String name : values.keySet())
outState.putLongArray(name, Helper.toLongArray(values.get(name))); outState.putLongArray(name, Helper.toLongArray(values.get(name)));
if (rvMessage != null) {
Parcelable rv = rvMessage.getLayoutManager().onSaveInstanceState();
outState.putParcelable("rv", rv);
}
if (selectionTracker != null) if (selectionTracker != null)
selectionTracker.onSaveInstanceState(outState); selectionTracker.onSaveInstanceState(outState);
} }
@ -1456,6 +1461,11 @@ public class FragmentMessages extends FragmentBase {
values.get(name).add(value); values.get(name).add(value);
} }
if (rvMessage != null) {
Parcelable rv = savedInstanceState.getBundle("rv");
rvMessage.getLayoutManager().onRestoreInstanceState(rv);
}
if (selectionTracker != null) if (selectionTracker != null)
selectionTracker.onRestoreInstanceState(savedInstanceState); selectionTracker.onRestoreInstanceState(savedInstanceState);
} }