diff options
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java | 12 | ||||
-rw-r--r-- | app/src/main/res/layout/item_post_detail_gallery.xml | 1 |
2 files changed, 12 insertions, 1 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 223dcf2b..49ce844e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -1460,6 +1460,13 @@ public class PostFragment extends Fragment implements FragmentCommunicator { break; } + int previousPosition = -1; + if (mLinearLayoutManager != null) { + previousPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); + } else if (mStaggeredGridLayoutManager != null) { + int[] into = new int[mStaggeredGridLayoutManager.getSpanCount()]; + previousPosition = mStaggeredGridLayoutManager.findFirstVisibleItemPositions(into)[0]; + } int nColumns = getNColumns(getResources()); if (nColumns == 1) { mLinearLayoutManager = new LinearLayoutManager(activity); @@ -1480,6 +1487,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mLinearLayoutManager = null; } + if (previousPosition > 0) { + mPostRecyclerView.scrollToPosition(previousPosition); + } + if (mAdapter != null) { mAdapter.setPostLayout(postLayout); refreshAdapter(); @@ -1925,7 +1936,6 @@ public class PostFragment extends Fragment implements FragmentCommunicator { mPostRecyclerView.setLayoutManager(null); mPostRecyclerView.setAdapter(mAdapter); mPostRecyclerView.setLayoutManager(layoutManager); - if (previousPosition > 0) { mPostRecyclerView.scrollToPosition(previousPosition); } diff --git a/app/src/main/res/layout/item_post_detail_gallery.xml b/app/src/main/res/layout/item_post_detail_gallery.xml index 7944c5c8..712a7725 100644 --- a/app/src/main/res/layout/item_post_detail_gallery.xml +++ b/app/src/main/res/layout/item_post_detail_gallery.xml @@ -224,6 +224,7 @@ android:layout_height="36dp" android:layout_margin="16dp" android:layout_gravity="start" + android:scaleType="center" android:background="@drawable/play_button_round_background" android:src="@drawable/ic_gallery_reverse_color_24dp" /> |