Browse Source

[컨텐츠상세][Common] 추천컨텐츠 인디케이터 스크롤 영역 수정

Hasemi 6 years ago
parent
commit
77557c4718

+ 18 - 4
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/recommend/RecommendContentsView.java

@@ -20,7 +20,8 @@ import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.bean.api.WithShownItemBean;
 import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.view.IEventListener;
-import kr.co.zumo.app.lifeplus.view.custom.category.banner.MainBannerViewItemDotIndicator;
+import kr.co.zumo.app.lifeplus.view.IndexScrollListener;
+import kr.co.zumo.app.lifeplus.view.screen.event.CustomIndicator;
 
 /**
  * RecommendContentsView
@@ -37,7 +38,10 @@ public class RecommendContentsView extends ConstraintLayout {
   private TextView textViewTitle;
   private TextView textViewSubTitle;
   private RecyclerView recyclerViewRecommendContents;
+  private CustomIndicator customIndicator;
   private List<WithShownItemBean> withItemList;
+  private IndexScrollListener indexScrollListener;
+  private LinearLayoutManager layoutManager;
 
   public RecommendContentsView(Context context) {
     super(context);
@@ -59,6 +63,9 @@ public class RecommendContentsView extends ConstraintLayout {
     inflater.inflate(R.layout.recommend_contents_view, this);
 
     recyclerViewRecommendContents = findViewById(R.id.recycler_view_recommend_contents);
+    customIndicator = findViewById(R.id.custom_indicator);
+    layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
+
     recyclerViewRecommendContents.addItemDecoration(new RecyclerView.ItemDecoration() {
       @Override
       public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
@@ -99,18 +106,25 @@ public class RecommendContentsView extends ConstraintLayout {
 
       }
     });
+
+    indexScrollListener = new IndexScrollListener(layoutManager, index -> {
+      customIndicator.onChangedIndex(index);
+    });
+
+    recyclerViewRecommendContents.addOnScrollListener(indexScrollListener);
+
   }
 
   public void draw(Context context, List<WithShownItemBean> withItemList, IEventListener listener) {
     this.withItemList = withItemList;
-
+    customIndicator.setIndicatorSetting(recyclerViewRecommendContents, R.color.C19000000, R.color.C000000, ResourceUtil.dpToPx(0));
     if (null == withItemList) {
       Log.e("APP#  RecommendContentsView | draw", "|" + "withItemList is null......");
       return;
     }
     RecommendContentsViewAdapter recommendContentsViewAdapter = new RecommendContentsViewAdapter(context, withItemList, listener);
-    recyclerViewRecommendContents.addItemDecoration(new MainBannerViewItemDotIndicator(context, R.color.C19000000, R.color.C000000, ResourceUtil.dpToPx(74)));
-    recyclerViewRecommendContents.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
+    // recyclerViewRecommendContents.addItemDecoration(new MainBannerViewItemDotIndicator(context, R.color.C19000000, R.color.C000000, ResourceUtil.dpToPx(74)));
+    recyclerViewRecommendContents.setLayoutManager(layoutManager);
     recyclerViewRecommendContents.setAdapter(recommendContentsViewAdapter);
 
   }

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

@@ -77,7 +77,11 @@ public class CustomIndicator extends View {
     float paddingBetweenItems = Math.max(0, itemCount - 1) * mIndicatorItemPadding;
     float indicatorTotalWidth = totalLength + paddingBetweenItems;
     float indicatorStartX = (recyclerView.getWidth() - indicatorTotalWidth) / 2F;
-    float indicatorPosY = getHeight() - 38F * DP;
+    //float indicatorPosY = getHeight() - 38F * DP;
+    float indicatorPosY = getHeight() - mIndicatorHeight / 2F;
+
+
+
     drawInactiveIndicators(canvas, indicatorStartX, indicatorPosY, itemCount);
     if (activePosition == RecyclerView.NO_POSITION) {
       return;

+ 11 - 1
app/src/main/res/layout/recommend_contents_view.xml

@@ -47,7 +47,7 @@
   <android.support.v7.widget.RecyclerView
     android:id="@+id/recycler_view_recommend_contents"
     android:layout_width="match_parent"
-    android:layout_height="385dp"
+    android:layout_height="311dp"
     android:layout_marginTop="35dp"
     android:clipToPadding="false"
     android:overScrollMode="never"
@@ -57,4 +57,14 @@
     app:layout_constraintStart_toStartOf="parent"
     app:layout_constraintTop_toBottomOf="@+id/text_view_sub_title"/>
 
+  <kr.co.zumo.app.lifeplus.view.screen.event.CustomIndicator
+    android:id="@+id/custom_indicator"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_marginBottom="33dp"
+    app:layout_constraintBottom_toBottomOf="parent"
+    app:layout_constraintEnd_toEndOf="parent"
+    app:layout_constraintStart_toStartOf="parent"
+    />
+
 </android.support.constraint.ConstraintLayout>