Browse Source

Save scrolling state

Infinite 3 năm trước cách đây
mục cha
commit
ee23be5bb3

+ 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