소스 검색

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