فهرست منبع

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