فهرست منبع

[카테고리메인][Bug] 아이템간 간격 일정하게 수정

Hasemi 7 سال پیش
والد
کامیت
927c9d258b

+ 1 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/dialog/CategoryFirstMainFilterDialog.java

@@ -28,7 +28,7 @@ import kr.co.zumo.app.lifeplus.view.custom.CustomSquareCheckBox;
  * @since 2018-11-01
  */
 
-public class CategoryFirstMainFilterDialog extends DialogBase {
+public class CategoryFirstMainFilterDialog extends DialogBase<I> {
 
   private static final int CATEGORY_FIRST_ID = 0;
   private static final int CATEGORY_SECOND_ID = 1;

+ 5 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/category/FirstCategoryMainAdapter.java

@@ -24,7 +24,7 @@ public class FirstCategoryMainAdapter extends RecyclerView.Adapter<RecyclerView.
   private Context context;
   private LayoutInflater inflater;
   public static final int GRID_VIEW_TYPE = 0;
-  public static final int LINEAR_VIEW_TYPE = 1;
+  public static final int BANNER_VIEW_TYPE = 1;
 
   public FirstCategoryMainAdapter(Context context) {
     this.context = context;
@@ -39,8 +39,8 @@ public class FirstCategoryMainAdapter extends RecyclerView.Adapter<RecyclerView.
       case GRID_VIEW_TYPE:
         view = inflater.inflate(R.layout.main_first_category_grid_view, parent, false);
         return new FirstCategoryMainGridViewHolder(view);
-      case LINEAR_VIEW_TYPE:
-        view = inflater.inflate(R.layout.main_first_category_linear_view, parent, false);
+      case BANNER_VIEW_TYPE:
+        view = inflater.inflate(R.layout.main_first_category_banner_view, parent, false);
         return new FirstCategoryMainLinearViewHolder(view);
       default:
         break;
@@ -56,7 +56,7 @@ public class FirstCategoryMainAdapter extends RecyclerView.Adapter<RecyclerView.
       case GRID_VIEW_TYPE:
         ((FirstCategoryMainGridViewHolder) holder).doDataSetting();
         break;
-      case LINEAR_VIEW_TYPE:
+      case BANNER_VIEW_TYPE:
         ((FirstCategoryMainLinearViewHolder) holder).doDataSetting();
         break;
       default:
@@ -74,7 +74,7 @@ public class FirstCategoryMainAdapter extends RecyclerView.Adapter<RecyclerView.
   @Override
   public int getItemViewType(int position) {
     if (position == 4) {
-      return LINEAR_VIEW_TYPE;
+      return BANNER_VIEW_TYPE;
     }
     else {
       return GRID_VIEW_TYPE;

+ 3 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/category/FirstCategoryMainFragment.java

@@ -19,6 +19,7 @@ import kr.co.zumo.app.lifeplus.bean.TextImageBean;
 import kr.co.zumo.app.lifeplus.manager.ActionBarManager;
 import kr.co.zumo.app.lifeplus.manager.IActionBarListener;
 import kr.co.zumo.app.lifeplus.model.BlankModel;
+import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.view.Event;
 import kr.co.zumo.app.lifeplus.view.custom.main.series.IMainSeriesContract;
 import kr.co.zumo.app.lifeplus.view.custom.main.series.MainSeriesPresenter;
@@ -70,7 +71,7 @@ public class FirstCategoryMainFragment extends FragmentBase<FirstCategoryMainPre
           case FirstCategoryMainAdapter.GRID_VIEW_TYPE:
             //리싸이클러뷰 영역 한개 원래대로씀
             return 1;
-          case FirstCategoryMainAdapter.LINEAR_VIEW_TYPE:
+          case FirstCategoryMainAdapter.BANNER_VIEW_TYPE:
             //리싸이클러뷰 영역 2개를 합침
             return 2;
           default:
@@ -79,7 +80,7 @@ public class FirstCategoryMainFragment extends FragmentBase<FirstCategoryMainPre
         return 0;
       }
     });
-    recyclerViewFirstCategoryMain.addItemDecoration(new GridItemDecoration());
+    recyclerViewFirstCategoryMain.addItemDecoration(new GridItemDecoration(getActivity(), ResourceUtil.dpToPx(4)));
     recyclerViewFirstCategoryMain.setLayoutManager(gridLayoutManager);
     recyclerViewFirstCategoryMain.setAdapter(firstCategoryMainAdapter);
 

+ 25 - 31
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/category/GridItemDecoration.java

@@ -1,7 +1,7 @@
 package kr.co.zumo.app.lifeplus.view.screen.main.category;
 
+import android.content.Context;
 import android.graphics.Rect;
-import android.support.v7.widget.GridLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.View;
 
@@ -18,39 +18,33 @@ import kr.co.zumo.app.lifeplus.util.ResourceUtil;
  * @since 2018-10-23
  */
 public class GridItemDecoration extends RecyclerView.ItemDecoration {
-  private int mHorizontalSpacing = ResourceUtil.dpToPx(9);
-  private int mVerticalSpacing = ResourceUtil.dpToPx(9);
+
+  private static final int BANNER_VIEW_TYPE = 1;
+  private Context context;
+  private int itemOffset;
+
+  public GridItemDecoration(Context context, int itemOffset) {
+    this.context = context;
+    this.itemOffset = itemOffset;
+  }
 
   @Override
-  public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state)
-  {
+  public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
+                             RecyclerView.State state) {
     super.getItemOffsets(outRect, view, parent, state);
-    // Only handle the vertical situation
-    int position = parent.getChildPosition(view);
-    if (parent.getLayoutManager() instanceof GridLayoutManager)
-    {
-      GridLayoutManager layoutManager = (GridLayoutManager) parent.getLayoutManager();
-      int spanCount, column;
-      // Check the last item and is alone. Then set the parent's width
-      if (position == parent.getAdapter().getItemCount() - 1 && position % 2 == 0)
-      {
-        spanCount = 1;
-        outRect.left = mHorizontalSpacing;
-        outRect.right = parent.getWidth() - mHorizontalSpacing;
-      }
-      else
-      {
-        spanCount = layoutManager.getSpanCount();
-        column = position % spanCount;
-        outRect.left = mHorizontalSpacing * (spanCount - column) / spanCount;
-        outRect.right = mHorizontalSpacing * (column + 1) / spanCount;
-      }
-
-      if (position < spanCount)
-      {
-        outRect.top = mVerticalSpacing;
-      }
-      outRect.bottom = mVerticalSpacing;
+
+    int position = parent.getChildAdapterPosition(view);
+    int itemViewType = parent.getAdapter().getItemViewType(position);
+    //배너일때
+    if (itemViewType == BANNER_VIEW_TYPE) {
+      outRect.left = itemOffset;
+      outRect.right = itemOffset;
+      outRect.top = ResourceUtil.dpToPx(35);
+      outRect.bottom = ResourceUtil.dpToPx(35);
+    }
+    else {
+      outRect.set(itemOffset, itemOffset, itemOffset, itemOffset);
     }
+
   }
 }

+ 1 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/category/SecondCategoryMainFragment.java

@@ -66,7 +66,7 @@ public class SecondCategoryMainFragment extends FragmentBase<SecondCategoryMainP
       @Override
       public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
         super.getItemOffsets(outRect, view, parent, state);
-        outRect.bottom = ResourceUtil.dpToPx(7);
+        outRect.bottom = ResourceUtil.dpToPx(4);
       }
     });
 

+ 5 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/category/ThirdCategoryMainAdapter.java

@@ -24,7 +24,7 @@ public class ThirdCategoryMainAdapter extends RecyclerView.Adapter<RecyclerView.
   private Context context;
   private LayoutInflater inflater;
   public static final int GRID_VIEW_TYPE = 0;
-  public static final int LINEAR_VIEW_TYPE = 1;
+  public static final int BANNER_VIEW_TYPE = 1;
 
 
   public ThirdCategoryMainAdapter(Context context) {
@@ -40,8 +40,8 @@ public class ThirdCategoryMainAdapter extends RecyclerView.Adapter<RecyclerView.
       case GRID_VIEW_TYPE:
         view = inflater.inflate(R.layout.main_third_category_grid_view, parent, false);
         return new ThirdCategoryMainGridViewHolder(view);
-      case LINEAR_VIEW_TYPE:
-        view = inflater.inflate(R.layout.main_third_category_linear_view, parent, false);
+      case BANNER_VIEW_TYPE:
+        view = inflater.inflate(R.layout.main_third_category_banner_view, parent, false);
         return new ThirdCategoryMainLinearViewHolder(view);
         default:
           break;
@@ -55,7 +55,7 @@ public class ThirdCategoryMainAdapter extends RecyclerView.Adapter<RecyclerView.
       case GRID_VIEW_TYPE:
         ((ThirdCategoryMainGridViewHolder) holder).doDataSetting();
         break;
-      case LINEAR_VIEW_TYPE:
+      case BANNER_VIEW_TYPE:
         ((ThirdCategoryMainLinearViewHolder) holder).doDataSetting();
         break;
       default:
@@ -72,7 +72,7 @@ public class ThirdCategoryMainAdapter extends RecyclerView.Adapter<RecyclerView.
   @Override
   public int getItemViewType(int position) {
     if (position == 4) {
-      return LINEAR_VIEW_TYPE;
+      return BANNER_VIEW_TYPE;
     }
     else {
       return GRID_VIEW_TYPE;

+ 3 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/category/ThirdCategoryMainFragment.java

@@ -19,6 +19,7 @@ import kr.co.zumo.app.lifeplus.bean.TextImageBean;
 import kr.co.zumo.app.lifeplus.manager.ActionBarManager;
 import kr.co.zumo.app.lifeplus.manager.IActionBarListener;
 import kr.co.zumo.app.lifeplus.model.BlankModel;
+import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.view.custom.main.series.IMainSeriesContract;
 import kr.co.zumo.app.lifeplus.view.custom.main.series.MainSeriesPresenter;
 import kr.co.zumo.app.lifeplus.view.custom.main.series.MainSeriesView;
@@ -67,7 +68,7 @@ public class ThirdCategoryMainFragment extends FragmentBase<ThirdCategoryMainPre
           case ThirdCategoryMainAdapter.GRID_VIEW_TYPE:
             //리싸이컬르뷰 영역 한개 원래대로씀
             return 1;
-          case ThirdCategoryMainAdapter.LINEAR_VIEW_TYPE:
+          case ThirdCategoryMainAdapter.BANNER_VIEW_TYPE:
             //리싸이클러뷰 영역 2개를 합침
             return 2;
           default:
@@ -76,7 +77,7 @@ public class ThirdCategoryMainFragment extends FragmentBase<ThirdCategoryMainPre
         return 0;
       }
     });
-    recyclerViewThirdCategoryMain.addItemDecoration(new GridItemDecoration());
+    recyclerViewThirdCategoryMain.addItemDecoration(new GridItemDecoration(getActivity(), ResourceUtil.dpToPx(8)));
     recyclerViewThirdCategoryMain.setLayoutManager(gridLayoutManager);
     recyclerViewThirdCategoryMain.setAdapter(thirdCategoryMainAdapter);
   }

+ 2 - 2
app/src/main/res/layout/fragment_category_main_second.xml

@@ -47,8 +47,8 @@
     android:id="@+id/recycler_view_second_category_main"
     android:layout_width="match_parent"
     android:layout_height="0dp"
-    android:layout_marginStart="16dp"
-    android:layout_marginEnd="16dp"
+    android:layout_marginStart="25dp"
+    android:layout_marginEnd="25dp"
     android:clipToPadding="false"
     app:layout_constraintBottom_toBottomOf="parent"
     app:layout_constraintLeft_toLeftOf="parent"

app/src/main/res/layout/main_first_category_linear_view.xml → app/src/main/res/layout/main_first_category_banner_view.xml


+ 1 - 1
app/src/main/res/layout/main_fourth_category_banner_view.xml

@@ -7,6 +7,6 @@
   <kr.co.zumo.app.lifeplus.view.custom.main.banner.MainBannerView
     android:id="@+id/main_banner_view_first_category"
     android:layout_width="match_parent"
-    android:layout_height="122dp"/>
+    android:layout_height="150dp"/>
 
 </android.support.constraint.ConstraintLayout>

+ 1 - 1
app/src/main/res/layout/main_third_category_linear_view.xml

@@ -7,6 +7,6 @@
   <kr.co.zumo.app.lifeplus.view.custom.main.banner.MainBannerView
     android:id="@+id/main_banner_view_first_category"
     android:layout_width="match_parent"
-    android:layout_height="122dp"/>
+    android:layout_height="150dp"/>
 
 </android.support.constraint.ConstraintLayout>

+ 8 - 6
app/src/main/res/layout/main_third_category_grid_view.xml

@@ -1,27 +1,29 @@
 <?xml version="1.0" encoding="utf-8"?>
 <android.support.constraint.ConstraintLayout
+  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"
-  xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="wrap_content">
-  
+
   <ImageView
     android:id="@+id/image_view_main_third_category"
     android:layout_width="match_parent"
     android:layout_height="148dp"
-    tools:src="@drawable/img_bestbucket_banner_5"
     android:scaleType="fitXY"
+    tools:src="@drawable/img_bestbucket_banner_5"
     />
 
   <TextView
     android:id="@+id/text_view_main_third_category"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:textSize="14sp"
-    android:textColor="@color/C000000"
-    android:lineSpacingExtra="6sp"
     android:layout_marginTop="11dp"
+    android:layout_marginBottom="9dp"
+    android:lineSpacingExtra="6sp"
+    android:textColor="@color/C000000"
+    android:textSize="14sp"
+    app:layout_constraintBottom_toBottomOf="parent"
     app:layout_constraintTop_toBottomOf="@+id/image_view_main_third_category"
     tools:text="샤오룽바오\n만들기"
     />