Browse Source

[메인][New] 더보기 버튼 위치 변경, 횡 스크롤 마지막 아이템 위치 변경

hyodong.min 7 years ago
parent
commit
739afc9321

+ 10 - 10
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainCategoryContentsAdapter.java

@@ -88,9 +88,9 @@ public class MainCategoryContentsAdapter extends RecyclerView.Adapter<MainCatego
           // event.getInteger() = contents index
           listener.onEvent(new Event.Builder(Event.CONTENTS).integer(event.getInteger()).string(bean.getCategoryNumber()).build());
           break;
-        case Event.MORE:
-          listener.onEvent(new Event.Builder(Event.MORE).string(bean.getCategoryNumber()).build());
-          break;
+//        case Event.MORE:
+//          listener.onEvent(new Event.Builder(Event.MORE).string(bean.getCategoryNumber()).build());
+//          break;
         default:
           break;
       }
@@ -118,13 +118,13 @@ public class MainCategoryContentsAdapter extends RecyclerView.Adapter<MainCatego
   @Override
   public int getItemViewType(int position) {
     int type;
-    int tail = bean.getContentsList().size() - 1;
-    if (tail == position) {
-      type = VIEW_TYPE_TAIL;
-    }
-    else {
-      type = VIEW_TYPE_IMAGE;
-    }
+//    int tail = bean.getContentsList().size() - 1;
+//    if (tail == position) {
+//      type = VIEW_TYPE_TAIL;
+//    }
+//    else {
+    type = VIEW_TYPE_IMAGE;
+//    }
     return type;
   }
 

+ 16 - 16
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainCategorySnapper.java

@@ -278,22 +278,22 @@ public class MainCategorySnapper extends RecyclerView.OnFlingListener {
           return;
         }
         int offset = snapOffset;
-        if (mRecyclerView.getChildAdapterPosition(targetView) == (mRecyclerView.getAdapter().getItemCount() - 1)) {
-          /**
-           * 보통 뷰일 때 스크롤 타겟 위치
-           * - 0 + offset
-           *
-           * 마지막 뷰일 때
-           * => offset = screenWidth - 마지막 뷰 사이즈
-           */
-          OrientationHelper helper = getOrientationHelper(layoutManager);
-          if (null != helper) {
-            offset = (helper.getEnd() - helper.getDecoratedMeasurement(targetView));
-          }
-//          Log.e("APP#  MainCategorySnapper | onTargetFound", "|" + "layoutManager.getWidth(): " + layoutManager.getWidth());
-//          Log.e("APP#  MainCategorySnapper | onTargetFound", "|" + "helper.getDecoratedMeasurement(targetView): " + helper.getDecoratedMeasurement(targetView));
-//          Log.e("APP#  MainCategorySnapper | onTargetFound", "|" + "offset: " + offset);
-        }
+//        if (mRecyclerView.getChildAdapterPosition(targetView) == (mRecyclerView.getAdapter().getItemCount() - 1)) {
+//          /**
+//           * 보통 뷰일 때 스크롤 타겟 위치
+//           * - 0 + offset
+//           *
+//           * 마지막 뷰일 때
+//           * => offset = screenWidth - 마지막 뷰 사이즈
+//           */
+//          OrientationHelper helper = getOrientationHelper(layoutManager);
+//          if (null != helper) {
+//            offset = (helper.getEnd() - helper.getDecoratedMeasurement(targetView));
+//          }
+////          Log.e("APP#  MainCategorySnapper | onTargetFound", "|" + "layoutManager.getWidth(): " + layoutManager.getWidth());
+////          Log.e("APP#  MainCategorySnapper | onTargetFound", "|" + "helper.getDecoratedMeasurement(targetView): " + helper.getDecoratedMeasurement(targetView));
+////          Log.e("APP#  MainCategorySnapper | onTargetFound", "|" + "offset: " + offset);
+//        }
         int[] snapDistances = calculateDistanceToFinalSnap(mRecyclerView.getLayoutManager(), targetView);
         final int dx;
         final int dy;

+ 25 - 11
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainContentsCategoryHolder.java

@@ -5,7 +5,6 @@ package kr.co.zumo.app.lifeplus.view.screen.main;
 
 import android.animation.ObjectAnimator;
 import android.content.Context;
-import android.os.Parcelable;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.MotionEvent;
@@ -14,6 +13,7 @@ import android.widget.TextView;
 
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.bean.api.MainContentsBean;
+import kr.co.zumo.app.lifeplus.model.SuperModel;
 import kr.co.zumo.app.lifeplus.supervisor.AnimatorManager;
 import kr.co.zumo.app.lifeplus.util.ResourceUtil;
 import kr.co.zumo.app.lifeplus.view.Event;
@@ -33,9 +33,19 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
 
   private RecyclerView recyclerView;
   private MainCategoryContentsAdapter adapter;
+  private TextView textView;
+  private View textMore;
+  private View imageMore;
 
   public MainContentsCategoryHolder(Context context, View view) {
     super(context, view);
+    recyclerView = itemView.findViewById(R.id.recycler_view_category);
+    int paddingRight = SuperModel.getInstance().getScreenWidth() - ResourceUtil.getDimension(R.dimen.main_contents_image_width)
+      - ResourceUtil.getDimension(R.dimen.main_contents_start_gap) - ResourceUtil.getDimension(R.dimen.main_contents_image_horizontal_padding_end);
+    recyclerView.setPadding(recyclerView.getPaddingLeft(), recyclerView.getPaddingTop(), paddingRight, recyclerView.getPaddingBottom());
+    textView = itemView.findViewById(R.id.text_title);
+    textMore = itemView.findViewById(R.id.text_more);
+    imageMore = itemView.findViewById(R.id.image_more);
   }
 
   @Override
@@ -61,9 +71,13 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
   public void init(int index, MainContentsBean bean, IEventListener listener) {
     this.index = index;
 
-    TextView textView = itemView.findViewById(R.id.text_title);
     textView.setText(bean.getCategoryName());
-    recyclerView = itemView.findViewById(R.id.recycler_view_category);
+    textMore.setOnClickListener(v -> {
+      listener.onEvent(new Event.Builder(Event.MORE).string(bean.getCategoryNumber()).build());
+    });
+    imageMore.setOnClickListener(v -> {
+      listener.onEvent(new Event.Builder(Event.MORE).string(bean.getCategoryNumber()).build());
+    });
 
     // 첫 번째 카테고리만 에니메이션 적용
     if (this.index == 1 && AnimatorManager.getInstance().isCompleted() == false) {
@@ -111,9 +125,9 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
           // event.getInteger() = contents index
           listener.onEvent(event.clone().index(index).build());
           break;
-        case Event.MORE:
-          listener.onEvent(event);
-          break;
+//        case Event.MORE:
+//          listener.onEvent(event);
+//          break;
         default:
           break;
       }
@@ -166,8 +180,8 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
       });
     }
 
-    Parcelable state = MainModelHelper.getInstance().getInstanceState(this.index);
-    recyclerView.getLayoutManager().onRestoreInstanceState(state);
+//    Parcelable state = MainModelHelper.getInstance().getInstanceState(this.index);
+//    recyclerView.getLayoutManager().onRestoreInstanceState(state);
   }
 
   int oldX;
@@ -227,9 +241,9 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
       adapter = null;
     }
 
-    if (null != recyclerView) {
-      MainModelHelper.getInstance().addInstanceState(this.index, recyclerView.getLayoutManager().onSaveInstanceState());
-    }
+//    if (null != recyclerView) {
+//      MainModelHelper.getInstance().addInstanceState(this.index, recyclerView.getLayoutManager().onSaveInstanceState());
+//    }
   }
 
   private int getScreenY(View view) {

+ 1 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainModel.java

@@ -8,7 +8,6 @@ import java.util.ArrayList;
 import io.reactivex.disposables.Disposable;
 import kr.co.zumo.app.lifeplus.bean.api.LoginResultBean;
 import kr.co.zumo.app.lifeplus.bean.api.MainContentsBean;
-import kr.co.zumo.app.lifeplus.bean.api.MainContentsCategoryBean;
 import kr.co.zumo.app.lifeplus.bean.api.MainContentsResultBean;
 import kr.co.zumo.app.lifeplus.bean.api.RequestBean;
 import kr.co.zumo.app.lifeplus.model.Model;
@@ -100,7 +99,7 @@ public class MainModel extends Model {
 
         for (MainContentsBean contentsBean : contentsBeans) {
           // 카테고리 마지막에 dummy data 추가
-          contentsBean.getContentsList().add(new MainContentsCategoryBean());
+//          contentsBean.getContentsList().add(new MainContentsCategoryBean());
 
           // fixme for test 모든 컨텐츠에 북마크 하기.
 

+ 16 - 0
app/src/main/res/drawable/icon_main_arrow.xml

@@ -0,0 +1,16 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="6dp"
+    android:height="9dp"
+    android:viewportWidth="24"
+    android:viewportHeight="38">
+  <path
+      android:pathData="M-1344,-1564H96V996h-1440z"
+      android:fillColor="#FFF"
+      android:fillType="evenOdd"/>
+  <path
+      android:pathData="M6,32l15,-14L6,4"
+      android:strokeWidth="3.478"
+      android:fillColor="#00000000"
+      android:strokeColor="#999"
+      android:fillType="evenOdd"/>
+</vector>

+ 35 - 2
app/src/main/res/layout/main_contents_category.xml

@@ -13,7 +13,7 @@
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:paddingStart="@dimen/main_contents_start_gap"
-    android:paddingBottom="12dp"
+    android:paddingBottom="6dp"
     app:layout_constraintBottom_toTopOf="@+id/recycler_view_category">
 
     <TextView
@@ -23,18 +23,51 @@
       android:textColor="@color/C333333"
       android:textSize="19sp"
       android:textStyle="bold"
+      app:layout_constraintTop_toTopOf="parent"
+      app:layout_constraintVertical_bias="0"
       tools:text="주말에 뭐하지"
       />
+
+    <TextView
+      android:id="@+id/text_more"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:paddingStart="9dp"
+      android:paddingTop="9dp"
+      android:paddingBottom="9dp"
+      android:text="@string/more_contents"
+      android:textColor="@color/C999999"
+      android:textSize="12sp"
+      app:layout_constraintBottom_toBottomOf="parent"
+      app:layout_constraintEnd_toStartOf="@+id/image_more"/>
+
+    <ImageView
+      android:id="@+id/image_more"
+      android:layout_width="7dp"
+      android:layout_height="34dp"
+      app:layout_constraintBottom_toBottomOf="@+id/text_more"
+      app:layout_constraintEnd_toStartOf="@+id/guide_end"
+      app:layout_constraintTop_toTopOf="@+id/text_more"
+      app:srcCompat="@drawable/icon_main_arrow"/>
+
+    <android.support.constraint.Guideline
+      android:id="@+id/guide_end"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent"
+      android:orientation="vertical"
+      app:layout_constraintGuide_begin="@dimen/main_contents_image_width"/>
   </android.support.constraint.ConstraintLayout>
 
   <android.support.v7.widget.RecyclerView
     android:id="@+id/recycler_view_category"
-    android:layout_width="match_parent"
+    android:layout_width="0dp"
     android:layout_height="@dimen/main_contents_image_height"
     android:clipToPadding="false"
     android:orientation="horizontal"
     android:paddingStart="@dimen/main_contents_start_gap"
+    app:layout_constrainedWidth="true"
     app:layout_constraintBottom_toBottomOf="parent"
     app:layout_constraintTop_toTopOf="parent"/>
 
+
 </android.support.constraint.ConstraintLayout>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -707,6 +707,7 @@
   <string name="slash">" / "</string>
 
   <string name="quit_app">앱 종료</string>
+  <string name="more_contents">더보기</string>
 
   <!-- 임의 추가 문자열 : 시작 -->
   <string name="undefined_error">알 수 없는 에러</string>