Browse Source

[카테고리][Bug] 여행 어디가지, 레이아웃 수정

hyodong.min 7 years ago
parent
commit
74463fd8ff

+ 2 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/bean/CategoryBannerListBean.java

@@ -6,7 +6,7 @@ package kr.co.zumo.app.lifeplus.bean;
 import java.util.ArrayList;
 
 import kr.co.zumo.app.lifeplus.bean.api.CategoryBannerBean;
-import kr.co.zumo.app.lifeplus.bean.api.LifeplusContentsBean;
+import kr.co.zumo.app.lifeplus.bean.api.CategoryContentsBean;
 
 /**
  * CategoryBannerListBean
@@ -18,7 +18,7 @@ import kr.co.zumo.app.lifeplus.bean.api.LifeplusContentsBean;
  * @history 민효동   [2018. 11. 6.]   [최초 작성]
  * @since 2018. 11. 6.
  */
-public class CategoryBannerListBean extends LifeplusContentsBean {
+public class CategoryBannerListBean extends CategoryContentsBean {
   private ArrayList<CategoryBannerBean> bannerBeans;
 
   public CategoryBannerListBean(ArrayList<CategoryBannerBean> bannerBeans) {

+ 36 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/bean/api/CategoryContentsListBean.java

@@ -0,0 +1,36 @@
+/*
+ * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
+ */
+package kr.co.zumo.app.lifeplus.bean.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * CategoryContentsListBean
+ * <pre>
+ * </pre>
+ *
+ * @author 민효동
+ * @version 1.0
+ * @history 민효동   [2018. 11. 22.]   [최초 작성]
+ * @since 2018. 11. 22.
+ */
+public class CategoryContentsListBean extends CategoryContentsBean {
+  private List<CategoryContentsBean> contentsList;
+
+  public List<CategoryContentsBean> getContentsList() {
+    return contentsList;
+  }
+
+  public void setContentsList(List<CategoryContentsBean> contentsList) {
+    this.contentsList = contentsList;
+  }
+
+  public void addContents(CategoryContentsBean bean) {
+    if (null == contentsList) {
+      contentsList = new ArrayList<>();
+    }
+    contentsList.add(bean);
+  }
+}

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

@@ -3,7 +3,7 @@ package kr.co.zumo.app.lifeplus.view.screen.category;
 import android.support.v7.widget.RecyclerView;
 import android.view.View;
 
-import kr.co.zumo.app.lifeplus.bean.api.LifeplusContentsBean;
+import kr.co.zumo.app.lifeplus.bean.api.CategoryContentsBean;
 import kr.co.zumo.app.lifeplus.view.IEventListener;
 
 /**
@@ -16,7 +16,7 @@ import kr.co.zumo.app.lifeplus.view.IEventListener;
  * @history 하세미   [2018-10-23]   [최초 작성]
  * @since 2018-10-23
  */
-public abstract class CategoryMainViewHolder<T extends LifeplusContentsBean> extends RecyclerView.ViewHolder {
+public abstract class CategoryMainViewHolder<T extends CategoryContentsBean> extends RecyclerView.ViewHolder {
 
   protected int index;
   protected T bean;

+ 21 - 8
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/category/type2/SecondCategoryMainAdapter.java

@@ -12,8 +12,8 @@ import java.util.ArrayList;
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.bean.api.CategoryBannerBean;
 import kr.co.zumo.app.lifeplus.bean.api.CategoryContentsBean;
+import kr.co.zumo.app.lifeplus.bean.api.CategoryContentsListBean;
 import kr.co.zumo.app.lifeplus.view.IEventListener;
-import kr.co.zumo.app.lifeplus.view.screen.category.CategoryMainViewHolder;
 
 /**
  * SecondCategoryMainAdapter
@@ -25,7 +25,7 @@ import kr.co.zumo.app.lifeplus.view.screen.category.CategoryMainViewHolder;
  * @history 하세미   [2018-10-24]   [최초 작성]
  * @since 2018-10-24
  */
-public class SecondCategoryMainAdapter extends RecyclerView.Adapter<CategoryMainViewHolder> {
+public class SecondCategoryMainAdapter extends RecyclerView.Adapter<SecondCategoryMainHolder> {
 
   public static final int FIRST_ROW = 0;
   public static final int SECOND_ROW = 1;
@@ -48,7 +48,7 @@ public class SecondCategoryMainAdapter extends RecyclerView.Adapter<CategoryMain
 
   @NonNull
   @Override
-  public CategoryMainViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+  public SecondCategoryMainHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
     View view;
 
     switch (viewType) {
@@ -63,14 +63,27 @@ public class SecondCategoryMainAdapter extends RecyclerView.Adapter<CategoryMain
         return new SecondCategoryThirdItemViewHolder(view);
       default:
         break;
-
     }
     return null;
   }
 
   @Override
-  public void onBindViewHolder(@NonNull CategoryMainViewHolder holder, int position) {
-    holder.bind(position, contentsBeans.get(position), event -> {
+  public void onBindViewHolder(@NonNull SecondCategoryMainHolder holder, int position) {
+    // 0 -> 0, 1, 2,
+    // 1 -> 3, 4, 5
+    int startIndex = position * 3;
+    CategoryContentsListBean categoryContentsListBean = new CategoryContentsListBean();
+    for (int i = 0; i < 3; ++i) {
+      int index = startIndex + i;
+      if (contentsBeans.size() > index) {
+        categoryContentsListBean.addContents(contentsBeans.get(index));
+      }
+      else {
+        break;
+      }
+    }
+
+    holder.bind(position, categoryContentsListBean, event -> {
       if (null != listener) {
         listener.onEvent(event);
       }
@@ -78,12 +91,12 @@ public class SecondCategoryMainAdapter extends RecyclerView.Adapter<CategoryMain
   }
 
   @Override
-  public void onViewDetachedFromWindow(@NonNull CategoryMainViewHolder holder) {
+  public void onViewDetachedFromWindow(@NonNull SecondCategoryMainHolder holder) {
     holder.detach();
   }
 
   @Override
-  public void onViewAttachedToWindow(@NonNull CategoryMainViewHolder holder) {
+  public void onViewAttachedToWindow(@NonNull SecondCategoryMainHolder holder) {
     holder.attach();
   }
 

+ 29 - 38
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/category/type2/SecondCategoryMainHolder.java

@@ -10,6 +10,7 @@ import java.util.List;
 
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.bean.api.CategoryContentsBean;
+import kr.co.zumo.app.lifeplus.bean.api.CategoryContentsListBean;
 import kr.co.zumo.app.lifeplus.bean.api.TagBean;
 import kr.co.zumo.app.lifeplus.util.StringUtil;
 import kr.co.zumo.app.lifeplus.view.Event;
@@ -25,7 +26,7 @@ import kr.co.zumo.app.lifeplus.view.screen.category.CategoryMainViewHolder;
  * @history 하세미   [2018-10-31]   [최초 작성]
  * @since 2018-10-31
  */
-public abstract class SecondCategoryMainHolder extends CategoryMainViewHolder<CategoryContentsBean> {
+public abstract class SecondCategoryMainHolder extends CategoryMainViewHolder<CategoryContentsListBean> {
 
   protected ImageView imageView1;
   protected ImageView imageView2;
@@ -43,6 +44,10 @@ public abstract class SecondCategoryMainHolder extends CategoryMainViewHolder<Ca
   public void dispose() {
     imageView1 = null;
     textView1 = null;
+    imageView2 = null;
+    textView2 = null;
+    imageView3 = null;
+    textView3 = null;
   }
 
   @Override
@@ -54,10 +59,25 @@ public abstract class SecondCategoryMainHolder extends CategoryMainViewHolder<Ca
     imageView3 = itemView.findViewById(R.id.image_3);
     textView3 = itemView.findViewById(R.id.text_3);
 
+    ImageView[] images = {imageView1, imageView2, imageView3};
+    TextView[] texts = {textView1, textView2, textView3};
+
     if (null != bean) {
-      Glide.with(imageView1).load(bean.getImageUrl()).into(imageView1);
-      Glide.with(imageView2).load(bean.getImageUrl()).into(imageView2);
-      Glide.with(imageView3).load(bean.getImageUrl()).into(imageView3);
+      List<CategoryContentsBean> list = bean.getContentsList();
+      int len = list.size();
+      for (int i = 0; i < len; ++i) {
+        ImageView imageView = images[i];
+        TextView textView = texts[i];
+
+        setupView(i, list.get(i), imageView, textView);
+      }
+    }
+  }
+
+  private void setupView(int index, CategoryContentsBean bean, ImageView imageView, TextView textView) {
+
+    if (null != bean) {
+      Glide.with(imageView).load(bean.getImageUrl()).into(imageView);
 
       List<TagBean> list = bean.getTagList();
       StringBuilder stringBuilder = new StringBuilder();
@@ -73,51 +93,22 @@ public abstract class SecondCategoryMainHolder extends CategoryMainViewHolder<Ca
           }
         }
       }
-      textView1.setText(stringBuilder.toString());
-      textView2.setText(stringBuilder.toString());
-      textView3.setText(stringBuilder.toString());
+      textView.setText(stringBuilder.toString());
     }
 
-    imageView1.setOnClickListener(v -> {
+    imageView.setOnClickListener(v -> {
       if (null != listener) {
         listener.onEvent(new Event.Builder(Event.CONTENTS).index(index).build());
       }
     });
-
-    imageView2.setOnClickListener(v -> {
-      if (null != listener) {
-        listener.onEvent(new Event.Builder(Event.CONTENTS).index(index).build());
-      }
-    });
-    imageView3.setOnClickListener(v -> {
-      if (null != listener) {
-        listener.onEvent(new Event.Builder(Event.CONTENTS).index(index).build());
-      }
-    });
-
   }
 
   @Override
   public void detach() {
-    if (null != imageView1) {
-      Glide.with(imageView1).clear(imageView1);
-      imageView1.setOnClickListener(null);
-      imageView1 = null;
-      textView1 = null;
-    }
-
-    if (null != imageView2) {
-      Glide.with(imageView2).clear(imageView2);
-      imageView2.setOnClickListener(null);
-      imageView2 = null;
-      textView2 = null;
-    }
 
-    if (null != imageView3) {
-      Glide.with(imageView3).clear(imageView3);
-      imageView3.setOnClickListener(null);
-      imageView3 = null;
-      textView3 = null;
+    ImageView[] images = {imageView1, imageView1, imageView1};
+    for (ImageView image : images) {
+      Glide.with(image).clear(image);
     }
 
   }

+ 13 - 7
app/src/main/res/layout/main_second_category_first_row.xml

@@ -25,11 +25,11 @@
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:scaleType="centerCrop"
-      android:src="@drawable/banner_bg_1"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
+      tools:src="@drawable/banner_bg_1"
       />
 
     <TextView
@@ -86,13 +86,16 @@
           android:id="@+id/text_2"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
-          android:layout_marginStart="15dp"
-          android:layout_marginBottom="15dp"
+          android:layout_marginStart="10dp"
+          android:layout_marginEnd="10dp"
+          android:layout_marginBottom="10dp"
           android:lineSpacingExtra="6sp"
+          android:maxLines="2"
           android:textColor="@color/CFFFFFF"
           android:textSize="14sp"
           app:layout_constraintBottom_toBottomOf="parent"
           app:layout_constraintEnd_toEndOf="parent"
+          app:layout_constraintHorizontal_bias="0"
           app:layout_constraintStart_toStartOf="parent"
           tools:text="디즈니랜드 여행"/>
 
@@ -109,20 +112,23 @@
           android:layout_height="match_parent"
           android:layout_marginTop="7dp"
           android:scaleType="centerCrop"
-          android:src="@drawable/banner_bg_1"
-          app:layout_constraintBottom_toBottomOf="parent"/>
+          app:layout_constraintBottom_toBottomOf="parent"
+          tools:src="@drawable/banner_bg_1"/>
 
         <TextView
           android:id="@+id/text_3"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
-          android:layout_marginStart="15dp"
-          android:layout_marginBottom="15dp"
+          android:layout_marginStart="10dp"
+          android:layout_marginEnd="10dp"
+          android:layout_marginBottom="10dp"
           android:lineSpacingExtra="6sp"
+          android:maxLines="2"
           android:textColor="@color/CFFFFFF"
           android:textSize="14sp"
           app:layout_constraintBottom_toBottomOf="parent"
           app:layout_constraintEnd_toEndOf="parent"
+          app:layout_constraintHorizontal_bias="0"
           app:layout_constraintStart_toStartOf="parent"
           tools:text="디즈니랜드 여행"/>
       </android.support.constraint.ConstraintLayout>

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

@@ -48,12 +48,13 @@
           android:layout_height="wrap_content"
           android:layout_marginStart="10dp"
           android:layout_marginEnd="10dp"
-          android:layout_marginBottom="15dp"
+          android:layout_marginBottom="10dp"
           android:lineSpacingExtra="6sp"
-          android:maxLines="1"
+          android:maxLines="2"
           android:textColor="@color/CFFFFFF"
           android:textSize="14sp"
           app:layout_constraintBottom_toBottomOf="parent"
+          app:layout_constraintHorizontal_bias="0"
           app:layout_constraintEnd_toEndOf="parent"
           app:layout_constraintStart_toStartOf="parent"
           tools:text="디즈니랜드 여행"/>
@@ -71,7 +72,7 @@
           android:layout_height="match_parent"
           android:layout_marginTop="7dp"
           android:scaleType="centerCrop"
-          android:src="@drawable/banner_bg_1"
+          tools:src="@drawable/banner_bg_1"
           app:layout_constraintBottom_toBottomOf="parent"/>
 
         <TextView
@@ -80,12 +81,13 @@
           android:layout_height="wrap_content"
           android:layout_marginStart="10dp"
           android:layout_marginEnd="10dp"
-          android:layout_marginBottom="15dp"
+          android:layout_marginBottom="10dp"
           android:lineSpacingExtra="6sp"
-          android:maxLines="1"
+          android:maxLines="2"
           android:textColor="@color/CFFFFFF"
           android:textSize="14sp"
           app:layout_constraintBottom_toBottomOf="parent"
+          app:layout_constraintHorizontal_bias="0"
           app:layout_constraintEnd_toEndOf="parent"
           app:layout_constraintStart_toStartOf="parent"
 
@@ -110,7 +112,7 @@
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:scaleType="centerCrop"
-      android:src="@drawable/banner_bg_1"
+      tools:src="@drawable/banner_bg_1"
       app:layout_constraintBottom_toBottomOf="parent"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintStart_toStartOf="parent"

+ 11 - 5
app/src/main/res/layout/main_second_category_third_row.xml

@@ -24,23 +24,25 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scaleType="centerCrop"
-        android:src="@drawable/banner_bg_1"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent"/>
+        app:layout_constraintTop_toTopOf="parent"
+        tools:src="@drawable/banner_bg_1"/>
 
       <TextView
         android:id="@+id/text_1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginStart="10dp"
+        android:layout_marginEnd="10dp"
         android:layout_marginBottom="10dp"
         android:lineSpacingExtra="4sp"
         android:textColor="@color/CFFFFFF"
         android:textSize="12sp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0"
         app:layout_constraintStart_toStartOf="parent"
         tools:text="다국적 배낭여행"/>
 
@@ -58,23 +60,25 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scaleType="centerCrop"
-        android:src="@drawable/banner_bg_1"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
-        app:layout_constraintTop_toTopOf="parent"/>
+        app:layout_constraintTop_toTopOf="parent"
+        tools:src="@drawable/banner_bg_1"/>
 
       <TextView
         android:id="@+id/text_2"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginStart="10dp"
+        android:layout_marginEnd="10dp"
         android:layout_marginBottom="10dp"
         android:lineSpacingExtra="4sp"
         android:textColor="@color/CFFFFFF"
         android:textSize="12sp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0"
         app:layout_constraintStart_toStartOf="parent"
         tools:text="다국적 배낭여행"/>
     </android.support.constraint.ConstraintLayout>
@@ -93,11 +97,11 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scaleType="centerCrop"
-        android:src="@drawable/banner_bg_1"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent"
+        tools:src="@drawable/banner_bg_1"
         />
 
       <TextView
@@ -105,12 +109,14 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginStart="10dp"
+        android:layout_marginEnd="10dp"
         android:layout_marginBottom="10dp"
         android:lineSpacingExtra="4sp"
         android:textColor="@color/CFFFFFF"
         android:textSize="12sp"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0"
         app:layout_constraintStart_toStartOf="parent"
         tools:text="다국적 배낭여행"/>
     </android.support.constraint.ConstraintLayout>