mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Fix RecyclerView go to top after changing post type.
This commit is contained in:
parent
f2df7e94b1
commit
eaa24b4858
@ -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);
|
||||
}
|
||||
|
@ -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" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user