Browse Source

[공통][Common] 메인 배너 dim 유무 설정에 따라 레이아웃 분기 처리

Hasemi 7 years ago
parent
commit
7cedc2ab8f

+ 12 - 4
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/category/banner/MainBannerAdapter.java

@@ -29,25 +29,33 @@ public class MainBannerAdapter extends RecyclerView.Adapter<MainBannerViewHolder
   private Context context;
   private List<CategoryBannerBean> textImageBeanList;
   private LayoutInflater inflater;
+  private boolean isDimLayerEnabled;
 
-  public MainBannerAdapter(Context context, LayoutInflater inflater, List<CategoryBannerBean> textImageBeanList, IEventListener listener) {
+  public MainBannerAdapter(Context context, LayoutInflater inflater, List<CategoryBannerBean> textImageBeanList, IEventListener listener, boolean isDimLayerEnabled) {
     this.context = context;
     this.inflater = inflater;
     this.textImageBeanList = textImageBeanList;
     this.listener = listener;
+    this.isDimLayerEnabled = isDimLayerEnabled;
   }
 
   @NonNull
   @Override
   public MainBannerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
-    View view = inflater.inflate(R.layout.main_banner_view_item, parent, false);
+    View view;
+    if (isDimLayerEnabled) {
+      view = inflater.inflate(R.layout.main_banner_view_item_is_dim, parent, false);
+    }
+    else {
+      view = inflater.inflate(R.layout.main_banner_view_item_default, parent, false);
+    }
     return new MainBannerViewHolder(view);
   }
 
   @Override
   public void onBindViewHolder(@NonNull MainBannerViewHolder holder, int position) {
     holder.bind(position, textImageBeanList.get(position), event -> {
-      if(null != listener) {
+      if (null != listener) {
         listener.onEvent(event);
       }
     });
@@ -55,7 +63,7 @@ public class MainBannerAdapter extends RecyclerView.Adapter<MainBannerViewHolder
 
   @Override
   public void onViewDetachedFromWindow(@NonNull MainBannerViewHolder holder) {
-  //  holder.dispose();
+    //  holder.dispose();
   }
 
   @Override

+ 2 - 9
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/category/banner/MainBannerView.java

@@ -30,7 +30,6 @@ public class MainBannerView extends ConstraintLayout {
 
   private MainBannerAdapter mainBannerAdapter;
   private RecyclerView recyclerView;
-  private boolean isDimed;
 
   public MainBannerView(Context context) {
     super(context);
@@ -44,8 +43,7 @@ public class MainBannerView extends ConstraintLayout {
     super(context, attrs, defStyleAttr);
   }
 
-  public void init(Context context, List<CategoryBannerBean> textImageBeanList, IEventListener listener) {
-    isDimed = true;
+  public void init(Context context, List<CategoryBannerBean> textImageBeanList, IEventListener listener, boolean isDimLayerEnabled) {
 
     LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     inflater.inflate(R.layout.main_banner_view, this);
@@ -60,7 +58,7 @@ public class MainBannerView extends ConstraintLayout {
       if (null != listener) {
         listener.onEvent(event);
       }
-    });
+    }, isDimLayerEnabled);
     recyclerView.setOnFlingListener(null);
     snapHelper.attachToRecyclerView(recyclerView);
     recyclerView.setAdapter(mainBannerAdapter);
@@ -75,9 +73,4 @@ public class MainBannerView extends ConstraintLayout {
     recyclerView = null;
     mainBannerAdapter = null;
   }
-
-  public void isNotDimLayout() {
-    this.isDimed = false;
-  }
-
 }

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

@@ -62,7 +62,7 @@ public class PromotionDialog extends DialogBase {
       public void onEvent(Event event) {
         // todo event
       }
-    });
+    }, true);
   }
 
   public void doDataSetting() {

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

@@ -38,7 +38,7 @@ public class FirstCategoryMainBannerViewHolder extends CategoryMainViewHolder<Ca
         if (null != listener) {
           listener.onEvent(event);
         }
-      });
+      }, true);
     }
 
   }

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

@@ -38,7 +38,7 @@ public class ThirdCategoryMainBannerViewHolder extends CategoryMainViewHolder<Ca
         if (null != listener) {
           listener.onEvent(event);
         }
-      });
+      }, true);
     }
 
   }

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

@@ -40,7 +40,7 @@ public class FourthCategoryMainBannerViewHolder extends CategoryMainViewHolder<C
         if (null != listener) {
           listener.onEvent(event);
         }
-      });
+      }, true);
     }
   }
 

+ 1 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/my/coin/MyCoinMainFragment.java

@@ -59,7 +59,7 @@ public class MyCoinMainFragment extends FragmentBase<MyCoinMainPresenter> implem
       public void onEvent(Event event) {
 
       }
-    });
+    }, false);
 
     textViewMyCoinDetail.setOnClickListener(view -> {presenter.onEvent(new Event.Builder(Event.MY_COIN_DETAIL).build());});
     imageViewArrowMyCoinDetail.setOnClickListener(view -> {presenter.onEvent(new Event.Builder(Event.MY_COIN_DETAIL).build());});

+ 34 - 0
app/src/main/res/layout/main_banner_view_item_default.xml

@@ -0,0 +1,34 @@
+<?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"
+  android:layout_width="match_parent"
+  android:layout_height="match_parent">
+
+  <ImageView
+    android:id="@+id/image_view_banner_item"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:scaleType="centerCrop"
+    app:layout_constraintEnd_toEndOf="parent"
+    app:layout_constraintStart_toStartOf="parent"
+    tools:src="@drawable/img_bestbucket_banner_1"/>
+
+  <TextView
+    android:id="@+id/text_view_banner_item"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_marginStart="8dp"
+    android:layout_marginEnd="8dp"
+    android:gravity="center_horizontal"
+    android:lineSpacingExtra="8sp"
+    android:textColor="@color/CFFFFFF"
+    android:textSize="19sp"
+    app:layout_constraintBottom_toBottomOf="@+id/image_view_banner_item"
+    app:layout_constraintEnd_toEndOf="parent"
+    app:layout_constraintStart_toStartOf="parent"
+    app:layout_constraintTop_toTopOf="@+id/image_view_banner_item"
+    tools:text="베이징에서 접한
+신기한 문물 무인상점"/>
+</android.support.constraint.ConstraintLayout>

app/src/main/res/layout/main_banner_view_item.xml → app/src/main/res/layout/main_banner_view_item_is_dim.xml