Browse Source

[컨텐츠][New] RecyclerView paging

hyodong.min 7 years ago
parent
commit
9dcc1d8921

+ 2 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/helper/ActionBarHelper.java

@@ -226,7 +226,7 @@ public class ActionBarHelper extends Helper {
     else if (isTransparentBackground) {
       if (isScrollable) {
         // todo 스크롤되는 경우에는 appbar behavior 도 수정 필요;
-        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
+        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP);
         appBarLayoutParams.setBehavior(new CustomHeaderBehavior());
 
         // todo 스크롤되는 경우에는 appbar behavior 도 수정 필요;
@@ -240,7 +240,7 @@ public class ActionBarHelper extends Helper {
     }
     else {
       if (isScrollable) {
-        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
+        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP);
         appBarLayoutParams.setBehavior(new CustomHeaderBehavior());
 
         containerLayoutParams.setBehavior(null);

+ 5 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/contents/CustomListicleImageView.java

@@ -3,7 +3,9 @@ package kr.co.zumo.app.lifeplus.view.custom.contents;
 import android.content.Context;
 import android.support.constraint.ConstraintLayout;
 import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.PagerSnapHelper;
 import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.SnapHelper;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
@@ -57,6 +59,9 @@ public class CustomListicleImageView extends ConstraintLayout {
     layoutPager = findViewById(R.id.layout_pager);
 
     recyclerView = findViewById(R.id.recycler_view_listicle_view);
+
+    SnapHelper snapHelper = new PagerSnapHelper();
+    snapHelper.attachToRecyclerView(recyclerView);
   }
 
   public CustomListicleImageView(Context context, AttributeSet attrs) {

+ 2 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/contents/ContentsDetailFragment.java

@@ -47,8 +47,8 @@ public class ContentsDetailFragment extends FragmentBase<ContentsDetailPresenter
   @Override
   protected void onAfterActivityCreated(Bundle savedInstanceState) {
     recyclerViewContentsDetail = findViewById(R.id.recycler_view_contents_detail);
-//    Snapper snapper = new Snapper(recyclerViewContentsDetail, 800);
-//    snapper.attachToRecyclerView(recyclerViewContentsDetail);
+    SnapHelper snapHelper = new PagerSnapHelper();
+    snapHelper.attachToRecyclerView(recyclerViewContentsDetail);
   }
 
   @Override

+ 1 - 0
app/src/main/res/layout/custom_listicle_image_view.xml

@@ -3,6 +3,7 @@
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
+  android:descendantFocusability="blocksDescendants"
   android:layout_width="match_parent"
   android:layout_height="match_parent">