|
|
@@ -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);
|
|
|
}
|
|
|
|
|
|
}
|