Browse Source

[메인][New] 가로 스냅핑
- 마지막 작은 크기의 홀더가 미비

hyodong.min 7 years ago
parent
commit
413124dde7

+ 3 - 4
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/Snapper.java

@@ -8,7 +8,6 @@ import android.support.v7.widget.LinearSnapHelper;
 import android.support.v7.widget.OrientationHelper;
 import android.support.v7.widget.RecyclerView;
 import android.util.DisplayMetrics;
-import android.util.Log;
 import android.view.View;
 import android.view.animation.DecelerateInterpolator;
 import android.widget.Scroller;
@@ -46,7 +45,7 @@ public class Snapper extends LinearSnapHelper {
 
   @Override
   public boolean onFling(int velocityX, int velocityY) {
-    Log.w("APP# Snapper | onFling", "|" + "velociyX: " + velocityX);
+//    Log.w("APP# Snapper | onFling", "|" + "velocityX: " + velocityX);
     Scroller mGravityScroller = new Scroller(recyclerView.getContext(), new DecelerateInterpolator());
     mGravityScroller.fling(0, 0, velocityX, velocityY, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE);
 //      Log.w("APP# MainBannerView | onFling", "| " + mGravityScroller.getFinalX());
@@ -76,7 +75,7 @@ public class Snapper extends LinearSnapHelper {
     }
 
     int targetPosition = findTargetSnapPosition(layoutManager, velocityX, velocityY);
-    Log.w("APP# Snapper | snapFromFling2", "|" + "targetPosition: " + targetPosition);
+//    Log.w("APP# Snapper | snapFromFling2", "|" + "targetPosition: " + targetPosition);
     if (targetPosition == RecyclerView.NO_POSITION) {
       return false;
     }
@@ -141,7 +140,7 @@ public class Snapper extends LinearSnapHelper {
     }
 
     int deltaJump = layoutManager.canScrollVertically() ? vDeltaJump : hDeltaJump;
-    Log.i("APP# Snapper | findTargetSnapPosition", "|" + "deltaJump: " + deltaJump);
+//    Log.i("APP# Snapper | findTargetSnapPosition", "|" + "deltaJump: " + deltaJump);
     if (deltaJump == 0) {
       return RecyclerView.NO_POSITION;
     }

+ 5 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainCategoryContentsImageView.java

@@ -342,7 +342,11 @@ public class MainCategoryContentsImageView extends MainCategoryContentsView {
   @Override
   public void dispose() {
     if (null != imageView) {
-      Glide.with(imageView).clear(imageView);
+      try {
+        Glide.with(imageView).clear(imageView);
+      } catch (Exception e) {
+        e.printStackTrace();
+      }
       imageView.setOnClickListener(null);
       imageView = null;
       textBig = null;

+ 6 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainContentsCategoryHolder.java

@@ -14,6 +14,7 @@ import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.bean.api.MainContentsBean;
 import kr.co.zumo.app.lifeplus.view.Event;
 import kr.co.zumo.app.lifeplus.view.IEventListener;
+import kr.co.zumo.app.lifeplus.view.custom.Snapper;
 
 /**
  * MainContentsCategoryHolder
@@ -64,6 +65,11 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
 
     recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
 
+    if(recyclerView.getOnFlingListener() == null) {
+      Snapper snapper = new Snapper(recyclerView, 1000);
+      snapper.attachToRecyclerView(recyclerView);
+    }
+
     adapter = new MainCategoryContentsAdapter(context, bean, event -> {
       /**
        * more 는 그대로 전송하고

+ 5 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainFragment.java

@@ -68,6 +68,11 @@ public class MainFragment extends FragmentBase<MainPresenter> implements IMainVi
 
     contentsRecyclerView = findViewById(R.id.recycler_view_main);
 
+//    if(contentsRecyclerView.getOnFlingListener() == null) {
+//      Snapper snapper = new Snapper(contentsRecyclerView, 1000);
+//      snapper.attachToRecyclerView(contentsRecyclerView);
+//    }
+
 //    actionBarManager.setScrollListener(actionBarScrollListener);
 
     if (AppUtil.isDebug()) {