Переглянути джерело

[콘텐츠상세][Common] 카드 카드리스티클형 페이징 처리

Hasemi 7 роки тому
батько
коміт
20acafc861

+ 2 - 11
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/contents/ContentsCardHolder.java

@@ -1,7 +1,6 @@
 package kr.co.zumo.app.lifeplus.view.screen.contents;
 
 import android.graphics.Bitmap;
-import android.graphics.Typeface;
 import android.support.annotation.CallSuper;
 import android.support.annotation.Nullable;
 import android.support.constraint.ConstraintLayout;
@@ -9,7 +8,6 @@ import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageView;
-import android.widget.TextView;
 
 import com.bumptech.glide.Glide;
 import com.bumptech.glide.load.DataSource;
@@ -38,21 +36,17 @@ import kr.co.zumo.app.lifeplus.view.Visibler;
 public class ContentsCardHolder extends ContentsHolder<ContentsDetailBean> {
 
   protected ImageView imageViewCardListicleCover;
-  protected TextView textViewPageNumber;
   protected ConstraintLayout layoutMoreInfo;
   protected View dim0;
   protected View dim1;
-  protected View dim2;
 
   public ContentsCardHolder(View itemView) {
     super(itemView);
     imageViewCardListicleCover = itemView.findViewById(R.id.image_view);
-    textViewPageNumber = itemView.findViewById(R.id.text_view_page_number);
     layoutMoreInfo = itemView.findViewById(R.id.layout_more_info);
     dim0 = itemView.findViewById(R.id.view_dim_0);
     dim1 = itemView.findViewById(R.id.view_dim_1);
-    dim2 = itemView.findViewById(R.id.view_dim_2);
-    Visibler.invisible(dim0, dim1, dim2);
+    Visibler.invisible(dim0, dim1);
   }
 
   @CallSuper
@@ -72,7 +66,7 @@ public class ContentsCardHolder extends ContentsHolder<ContentsDetailBean> {
 
         @Override
         public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
-          Visibler.visible(dim0, dim1, dim2);
+          Visibler.visible(dim0, dim1);
           return false;
         }
       })
@@ -108,9 +102,6 @@ public class ContentsCardHolder extends ContentsHolder<ContentsDetailBean> {
         }
       }
     }
-
-    textViewPageNumber.setText(String.valueOf(getAdapterPosition()) + " / " + (itemCount - 1));
-    textViewPageNumber.setTypeface(null, Typeface.BOLD);
     layoutMoreInfo.setVisibility(View.GONE);
   }
 

+ 15 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/contents/ContentsFragment.java

@@ -2,6 +2,7 @@ package kr.co.zumo.app.lifeplus.view.screen.contents;
 
 import android.content.ActivityNotFoundException;
 import android.content.Intent;
+import android.graphics.Typeface;
 import android.net.Uri;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
@@ -16,6 +17,7 @@ import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.TextView;
 
 import java.util.List;
 
@@ -45,6 +47,8 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
   private ActionBarHelper actionBarHelper;
   private ContentsAdapter adapter;
   private LinearLayoutManager layoutManager;
+  private View dim;
+  private TextView textViewPageNumber;
 
   @Override
   protected View onAfterCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -54,6 +58,9 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
   @Override
   protected void onAfterActivityCreated(Bundle savedInstanceState) {
     recyclerViewContentsDetail = findViewById(R.id.recycler_view_contents_detail);
+    dim = findViewById(R.id.view_dim_2);
+    textViewPageNumber = findViewById(R.id.text_view_page_number);
+
     SnapHelper snapHelper = new PagerSnapHelper();
     snapHelper.attachToRecyclerView(recyclerViewContentsDetail);
 
@@ -239,6 +246,14 @@ public class ContentsFragment extends FragmentBase<ContentsPresenter> implements
     return holder.dispatchBackPressed();
   }
 
+  @Override
+  public void setCardPageNumber(String pageNumber) {
+    dim.setVisibility(View.VISIBLE);
+    textViewPageNumber.setVisibility(View.VISIBLE);
+    textViewPageNumber.setText(pageNumber);
+    textViewPageNumber.setTypeface(null, Typeface.BOLD);
+  }
+
   private int currentPageIndex = 0;
   private RecyclerView.OnScrollListener scrollEventListener = new RecyclerView.OnScrollListener() {
     @Override

+ 7 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/contents/ContentsPresenter.java

@@ -424,7 +424,14 @@ public class ContentsPresenter extends ContentsBasePresenter<ContentsModel, ICon
 
     }
 
+    if (!model.getContentsType().equals(ContentsDetailBean.TYPE_LISTICLE) && model.getCurrentPageIndex() > 0) {
+      setCardPageNumber();
+    }
+
+  }
 
+  private void setCardPageNumber() {
+    view.setCardPageNumber(model.getCurrentPageIndex() + " / " + String.valueOf(model.getItemCount() - 1));
   }
 
   private void showMoreInfoPopup(int index) {

+ 2 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/contents/IContentsView.java

@@ -33,4 +33,6 @@ public interface IContentsView extends IContentsBaseView {
 
   boolean dispatchBackPressed();
 
+  void setCardPageNumber(String pageNumber);
+
 }

+ 0 - 24
app/src/main/res/layout/contents_card_listicle_detail.xml

@@ -81,28 +81,4 @@
     android:background="@drawable/card_dim_bottom_12"
     app:layout_constraintBottom_toBottomOf="parent"/>
 
-  <View
-    android:id="@+id/view_dim_2"
-    android:layout_width="166dp"
-    android:layout_height="162dp"
-    android:background="@drawable/dim_card_listicle_3"
-    app:layout_constraintBottom_toBottomOf="parent"
-    app:layout_constraintEnd_toEndOf="parent"/>
-
-  <TextView
-    android:id="@+id/text_view_page_number"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:layout_marginEnd="25dp"
-    android:layout_marginBottom="28dp"
-    android:gravity="end"
-    android:lineSpacingExtra="4sp"
-    android:textColor="@color/CFFFFFF"
-    android:textSize="12sp"
-    android:textStyle="bold"
-    app:layout_constraintBottom_toBottomOf="parent"
-    app:layout_constraintEnd_toEndOf="parent"
-    tools:text="1 / 5"
-    />
-
 </android.support.constraint.ConstraintLayout>

+ 28 - 2
app/src/main/res/layout/fragment_contents_detail.xml

@@ -3,13 +3,39 @@
   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:descendantFocusability="blocksDescendants"
   android:layout_width="match_parent"
-  android:layout_height="match_parent">
+  android:layout_height="match_parent"
+  android:descendantFocusability="blocksDescendants">
 
   <android.support.v7.widget.RecyclerView
     android:id="@+id/recycler_view_contents_detail"
     android:layout_width="match_parent"
     android:layout_height="match_parent"/>
 
+  <View
+    android:id="@+id/view_dim_2"
+    android:layout_width="166dp"
+    android:layout_height="162dp"
+    android:background="@drawable/dim_card_listicle_3"
+    android:visibility="gone"
+    app:layout_constraintBottom_toBottomOf="parent"
+    app:layout_constraintEnd_toEndOf="parent"/>
+
+  <TextView
+    android:id="@+id/text_view_page_number"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_marginEnd="25dp"
+    android:layout_marginBottom="28dp"
+    android:gravity="end"
+    android:lineSpacingExtra="4sp"
+    android:textColor="@color/CFFFFFF"
+    android:textSize="12sp"
+    android:textStyle="bold"
+    android:visibility="gone"
+    app:layout_constraintBottom_toBottomOf="parent"
+    app:layout_constraintEnd_toEndOf="parent"
+    tools:text="1 / 5"
+    />
+
 </android.support.constraint.ConstraintLayout>