浏览代码

Save scrolling state

Infinite 3 年之前
父节点
当前提交
ee23be5bb3
共有 2 个文件被更改,包括 3 次插入1 次删除
  1. 1 0
      app/build.gradle
  2. 2 1
      app/src/main/java/club/thepenguins/android/fragments/HomeFragment.java

+ 1 - 0
app/build.gradle

@@ -45,5 +45,6 @@ dependencies {
     implementation 'com.squareup.picasso:picasso:2.8'
     implementation 'org.jsoup:jsoup:1.11.1'
     implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
+    implementation "androidx.recyclerview:recyclerview:1.2.1"
 
 }

+ 2 - 1
app/src/main/java/club/thepenguins/android/fragments/HomeFragment.java

@@ -90,9 +90,10 @@ public class HomeFragment extends Fragment {
 
 
         adapter = new PostRecyclerAdapter(list, rootView.getContext());
-
+        adapter.setStateRestorationPolicy(RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY);
         recyclerView.setAdapter(adapter);
 
+
         swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
 
             @Override