Sfoglia il codice sorgente

[버킷][New] 마이 버킷리스트 스크롤 위치 유지

hyodong.min 6 anni fa
parent
commit
c51f1b015f

+ 3 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/my/bucketlist/MyBucketListFragment.java

@@ -62,6 +62,7 @@ public class MyBucketListFragment extends FragmentBase<MyBucketListPresenter> im
     tabLayoutBucketList = findViewById(R.id.tab_layout_bucket_list);
     recyclerViewMyBucketList = findViewById(R.id.recycler_view_my_bucket_list);
     textCompleteBucket = findViewById(R.id.text_view_bucket_list_count);
+    tabLayoutBucketList.setupWithViewPager(viewPagerBucketList, true);
 
     //완료된 버킷 count
     textCompleteBucket.setOnClickListener(view -> {
@@ -74,6 +75,8 @@ public class MyBucketListFragment extends FragmentBase<MyBucketListPresenter> im
       presenter.onEvent(new Event.Builder(Event.TOGGLE).bool(isClicked()).build());
     });
 
+    recyclerViewMyBucketList.setNestedScrollingEnabled(false);
+    recyclerViewMyBucketList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
     recyclerViewMyBucketList.addItemDecoration(new RecyclerView.ItemDecoration() {
       @Override
       public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
@@ -131,8 +134,6 @@ public class MyBucketListFragment extends FragmentBase<MyBucketListPresenter> im
         presenter.onEvent(event);
       }
     });
-    recyclerViewMyBucketList.setNestedScrollingEnabled(false);
-    recyclerViewMyBucketList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
     recyclerViewMyBucketList.setAdapter(adapter);
   }
 
@@ -142,7 +143,6 @@ public class MyBucketListFragment extends FragmentBase<MyBucketListPresenter> im
     pagerAdapter = new MyBucketListBannerPagerAdapter(getActivity(), bestBeans, event -> {
       presenter.onEvent(event);
     });
-    tabLayoutBucketList.setupWithViewPager(viewPagerBucketList, true);
     viewPagerBucketList.setAdapter(pagerAdapter);
   }
 

+ 120 - 118
app/src/main/res/layout/fragment_my_bucket_list.xml

@@ -1,134 +1,136 @@
 <?xml version="1.0" encoding="utf-8"?>
-<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
+<android.support.v4.widget.NestedScrollView
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  xmlns:app="http://schemas.android.com/apk/res-auto"
+  android:id="@+id/scroll_view"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent"
+  android:orientation="vertical">
+
+  <LinearLayout
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="wrap_content"
     android:orientation="vertical">
 
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="vertical">
-
-        <android.support.constraint.ConstraintLayout
-            android:id="@+id/first_layout"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toTopOf="parent">
+    <android.support.constraint.ConstraintLayout
+      android:id="@+id/first_layout"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      app:layout_constraintBottom_toBottomOf="parent"
+      app:layout_constraintEnd_toEndOf="parent"
+      app:layout_constraintStart_toStartOf="parent"
+      app:layout_constraintTop_toTopOf="parent">
 
-            <android.support.v4.view.ViewPager
-                android:id="@+id/view_pager_best_bucket_list"
-                android:layout_width="0dp"
-                android:layout_height="0dp"
-                app:layout_constraintBottom_toBottomOf="parent"
-                app:layout_constraintDimensionRatio="V, 360:174"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintStart_toStartOf="parent"
-                app:layout_constraintTop_toTopOf="parent" />
+      <android.support.v4.view.ViewPager
+        android:id="@+id/view_pager_best_bucket_list"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintDimensionRatio="V, 360:174"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent"/>
 
-            <android.support.design.widget.TabLayout
-                android:id="@+id/tab_layout_bucket_list"
-                android:layout_width="match_parent"
-                android:layout_height="10dp"
-                android:layout_alignBottom="@+id/view_pager_best_bucket_list"
-                android:layout_alignParentStart="true"
-                android:layout_marginBottom="10dp"
-                app:layout_constraintBottom_toBottomOf="@+id/view_pager_best_bucket_list"
-                app:layout_constraintEnd_toEndOf="@+id/view_pager_best_bucket_list"
-                app:layout_constraintStart_toStartOf="@+id/view_pager_best_bucket_list"
-                app:tabBackground="@drawable/best_bucket_tab_selector"
-                app:tabGravity="center"
-                app:tabIndicatorHeight="0dp"
-                app:tabPaddingStart="6dp"
-                app:tabPaddingEnd="6dp" />
-        </android.support.constraint.ConstraintLayout>
+      <android.support.design.widget.TabLayout
+        android:id="@+id/tab_layout_bucket_list"
+        android:layout_width="match_parent"
+        android:layout_height="10dp"
+        android:layout_alignBottom="@+id/view_pager_best_bucket_list"
+        android:layout_alignParentStart="true"
+        android:layout_marginBottom="10dp"
+        app:layout_constraintBottom_toBottomOf="@+id/view_pager_best_bucket_list"
+        app:layout_constraintEnd_toEndOf="@+id/view_pager_best_bucket_list"
+        app:layout_constraintStart_toStartOf="@+id/view_pager_best_bucket_list"
+        app:tabBackground="@drawable/best_bucket_tab_selector"
+        app:tabGravity="center"
+        app:tabIndicatorHeight="0dp"
+        app:tabPaddingEnd="6dp"
+        app:tabPaddingStart="6dp"/>
+    </android.support.constraint.ConstraintLayout>
 
-        <android.support.constraint.ConstraintLayout
-            android:id="@+id/second_layout"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginStart="25dp"
-            android:layout_marginTop="30dp"
-            android:orientation="vertical"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/first_layout">
+    <android.support.constraint.ConstraintLayout
+      android:id="@+id/second_layout"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_marginStart="25dp"
+      android:layout_marginTop="30dp"
+      android:orientation="vertical"
+      app:layout_constraintStart_toStartOf="parent"
+      app:layout_constraintTop_toBottomOf="@+id/first_layout">
 
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:lineSpacingExtra="4sp"
-                android:text="@string/bucket_list_my"
-                android:textColor="@color/C666666"
-                android:textSize="11sp" />
-        </android.support.constraint.ConstraintLayout>
+      <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:lineSpacingExtra="4sp"
+        android:text="@string/bucket_list_my"
+        android:textColor="@color/C666666"
+        android:textSize="11sp"/>
+    </android.support.constraint.ConstraintLayout>
 
-        <android.support.constraint.ConstraintLayout
-            android:id="@+id/third_layout"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:layout_marginStart="25dp"
-            android:layout_marginTop="3dp"
-            android:layout_marginEnd="25dp"
-            app:layout_constraintTop_toBottomOf="@+id/second_layout">
+    <android.support.constraint.ConstraintLayout
+      android:id="@+id/third_layout"
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_gravity="center"
+      android:layout_marginStart="25dp"
+      android:layout_marginTop="3dp"
+      android:layout_marginEnd="25dp"
+      app:layout_constraintTop_toBottomOf="@+id/second_layout">
 
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="버킷리스트"
-                android:textColor="#000000"
-                android:textSize="19sp" />
+      <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="버킷리스트"
+        android:textColor="#000000"
+        android:textSize="19sp"/>
 
-            <ImageView
-                android:id="@+id/image_view_bucket_check"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:paddingStart="5dp"
-                android:paddingTop="1dp"
-                android:paddingEnd="2dp"
-                android:paddingBottom="5dp"
-                app:layout_constraintEnd_toStartOf="@id/text_view_bucket_list_count"
-                app:srcCompat="@drawable/ic_icon_bucket_sorting_default" />
+      <ImageView
+        android:id="@+id/image_view_bucket_check"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingStart="5dp"
+        android:paddingTop="1dp"
+        android:paddingEnd="2dp"
+        android:paddingBottom="5dp"
+        app:layout_constraintEnd_toStartOf="@id/text_view_bucket_list_count"
+        app:srcCompat="@drawable/ic_icon_bucket_sorting_default"/>
 
-            <TextView
-                android:id="@+id/text_view_bucket_list_count"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="0"
-                android:textColor="@color/C999999"
-                android:textSize="16sp"
-                android:includeFontPadding="false"
-                android:paddingBottom="5dp"
-                android:paddingTop="1dp"
-                app:layout_constraintBottom_toBottomOf="@+id/image_view_bucket_check"
-                app:layout_constraintEnd_toEndOf="parent"
-                app:layout_constraintTop_toTopOf="@+id/image_view_bucket_check" />
-        </android.support.constraint.ConstraintLayout>
+      <TextView
+        android:id="@+id/text_view_bucket_list_count"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:includeFontPadding="false"
+        android:paddingTop="1dp"
+        android:paddingBottom="5dp"
+        android:text="0"
+        android:textColor="@color/C999999"
+        android:textSize="16sp"
+        app:layout_constraintBottom_toBottomOf="@+id/image_view_bucket_check"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="@+id/image_view_bucket_check"/>
+    </android.support.constraint.ConstraintLayout>
 
-        <android.support.constraint.ConstraintLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center"
-            android:layout_marginStart="25dp"
-            android:layout_marginTop="21dp"
-            android:layout_marginEnd="25dp"
-            android:layout_marginBottom="28dp"
-            android:descendantFocusability="blocksDescendants"
-            app:layout_constraintBottom_toBottomOf="parent"
-            app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintStart_toStartOf="parent"
-            app:layout_constraintTop_toBottomOf="@+id/third_layout">
+    <android.support.constraint.ConstraintLayout
+      android:layout_width="match_parent"
+      android:layout_height="wrap_content"
+      android:layout_gravity="center"
+      android:layout_marginStart="25dp"
+      android:layout_marginTop="21dp"
+      android:layout_marginEnd="25dp"
+      android:layout_marginBottom="28dp"
+      android:descendantFocusability="blocksDescendants"
+      app:layout_constraintBottom_toBottomOf="parent"
+      app:layout_constraintEnd_toEndOf="parent"
+      app:layout_constraintStart_toStartOf="parent"
+      app:layout_constraintTop_toBottomOf="@+id/third_layout">
 
-            <android.support.v7.widget.RecyclerView
-                android:id="@+id/recycler_view_my_bucket_list"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center"
-                android:layout_marginBottom="30dp"/>
+      <android.support.v7.widget.RecyclerView
+        android:id="@+id/recycler_view_my_bucket_list"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:layout_marginBottom="30dp"/>
 
-        </android.support.constraint.ConstraintLayout>
-    </LinearLayout>
+    </android.support.constraint.ConstraintLayout>
+  </LinearLayout>
 </android.support.v4.widget.NestedScrollView>