diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-05-15 06:16:20 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-05-15 06:16:20 +0000 |
commit | fe192131d835e909ae2c2604f97ade479b934e71 (patch) | |
tree | b1b9e3eb625b06ec506c94ba9db859dcbb6eb84d /app | |
parent | bb36cc79fdded7209a4848c85a37076d2cf7f064 (diff) | |
download | infinity-for-reddit-fe192131d835e909ae2c2604f97ade479b934e71.tar infinity-for-reddit-fe192131d835e909ae2c2604f97ade479b934e71.tar.gz infinity-for-reddit-fe192131d835e909ae2c2604f97ade479b934e71.tar.bz2 infinity-for-reddit-fe192131d835e909ae2c2604f97ade479b934e71.tar.lz infinity-for-reddit-fe192131d835e909ae2c2604f97ade479b934e71.tar.xz infinity-for-reddit-fe192131d835e909ae2c2604f97ade479b934e71.tar.zst infinity-for-reddit-fe192131d835e909ae2c2604f97ade479b934e71.zip |
Fix recyclerview not scroll to correct last place after changing orientation.
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index 19bfaeb5..a1edea83 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -374,12 +374,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mSwipeRefreshLayout.setEnabled(mSharedPreferences.getBoolean(SharedPreferencesUtils.PULL_TO_REFRESH, true)); mSwipeRefreshLayout.setOnRefreshListener(this::refresh); + int recyclerViewPosition = 0; int hideReadPostsIndex = 0; if (savedInstanceState != null) { - int recyclerViewPosition = savedInstanceState.getInt(RECYCLER_VIEW_POSITION_STATE); - if (recyclerViewPosition > 0) { - mPostRecyclerView.scrollToPosition(recyclerViewPosition); - } + recyclerViewPosition = savedInstanceState.getInt(RECYCLER_VIEW_POSITION_STATE); isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE); readPosts = savedInstanceState.getParcelableArrayList(READ_POST_LIST_STATE); @@ -855,6 +853,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator { windowWidth /= 2; } + if (recyclerViewPosition > 0) { + mPostRecyclerView.scrollToPosition(recyclerViewPosition); + } + mAdapter.setHideReadPostsIndex(hideReadPostsIndex); if (activity instanceof ActivityToolbarInterface) { |