mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-10-29 11:49:33 +00:00
Fix scroll position in episode list of podcast preview (#7862)
ID is needed so that `CoordinatorLayout` automatically saves its state
This commit is contained in:
parent
b65062d18d
commit
21a4d7d876
@ -104,6 +104,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
|
||||
private Feed feed;
|
||||
private Disposable disposable;
|
||||
private FeedItemListFragmentBinding viewBinding;
|
||||
private Pair<Integer, Integer> scrollPosition = null;
|
||||
|
||||
/**
|
||||
* Creates new ItemlistFragment which shows the Feeditems of a specific
|
||||
@ -248,6 +249,12 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
|
||||
viewBinding.recyclerView.getPaddingRight(), paddingBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
scrollPosition = viewBinding.recyclerView.getScrollPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
@ -654,6 +661,8 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
|
||||
adapter.updateItems(feed.getItems());
|
||||
adapter.setTotalNumberOfItems(result.second);
|
||||
updateToolbar();
|
||||
viewBinding.recyclerView.restoreScrollPosition(scrollPosition);
|
||||
scrollPosition = null;
|
||||
}, error -> {
|
||||
feed = null;
|
||||
refreshHeaderView();
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/coordinatorLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user