Parcourir la source

[마이][Common] 북마크 리스트 스크롤 수정

Hasemi il y a 7 ans
Parent
commit
b6013b8ff1

+ 27 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/my/bookmark/BookMarkListAdapter.java

@@ -29,6 +29,8 @@ public class BookMarkListAdapter extends RecyclerView.Adapter<BookMarkListView>
   private Context context;
   private ArrayList<BookmarkBean> bookmarkBeans;
   private IEventListener listener;
+  private static final int TITLE_TYPE = 0;
+  private static final int CONTENTS_TYPE = 1;
 
   public BookMarkListAdapter(Context context, ArrayList<BookmarkBean> bookmarkBeans, IEventListener listener) {
     this.context = context;
@@ -39,9 +41,20 @@ public class BookMarkListAdapter extends RecyclerView.Adapter<BookMarkListView>
 
   @NonNull
   @Override
-  public BookMarkListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
-    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.book_mark_list_view, parent, false);
-    return new BookMarkListViewHolder(view);
+  public BookMarkListView onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+    View view;
+    switch (viewType) {
+      case TITLE_TYPE:
+        view = LayoutInflater.from(parent.getContext()).inflate(R.layout.book_mark_title_view, parent, false);
+        return new BookMarkTitleViewHolder(view);
+      case CONTENTS_TYPE:
+        view = LayoutInflater.from(parent.getContext()).inflate(R.layout.book_mark_list_view, parent, false);
+        return new BookMarkListViewHolder(view);
+      default:
+        break;
+    }
+
+    return null;
   }
 
   @Override
@@ -62,6 +75,17 @@ public class BookMarkListAdapter extends RecyclerView.Adapter<BookMarkListView>
     });
   }
 
+  @Override
+  public int getItemViewType(int position) {
+    switch (position) {
+      case 0:
+        return TITLE_TYPE;
+      default:
+        return CONTENTS_TYPE;
+
+    }
+  }
+
   @Override
   public int getItemCount() {
     return bookmarkBeans.size();

+ 0 - 6
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/my/bookmark/BookMarkListFragment.java

@@ -11,7 +11,6 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
-import android.widget.TextView;
 
 import java.util.ArrayList;
 
@@ -39,8 +38,6 @@ public class BookMarkListFragment extends FragmentBase<BookMarkListPresenter> im
   private CustomSpinner customSpinnerBookmark;
   private ConstraintLayout layoutCategory;
 
-  private TextView textViewTitle;
-
 
   @Override
   protected View onAfterCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -61,18 +58,15 @@ public class BookMarkListFragment extends FragmentBase<BookMarkListPresenter> im
     });
     customSpinnerBookmark = findViewById(R.id.spinner_book_mark);
     layoutCategory = findViewById(R.id.category_layout);
-    textViewTitle = findViewById(R.id.text_view_title);
 
     customSpinnerBookmark.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
       @Override
       public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
         if (customSpinnerBookmark.getItemAtPosition(position).equals("카테고리별")) {
           layoutCategory.setVisibility(View.VISIBLE);
-          textViewTitle.setVisibility(View.VISIBLE);
         }
         else {
           layoutCategory.setVisibility(View.GONE);
-          textViewTitle.setVisibility(View.GONE);
         }
       }
 

+ 35 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/my/bookmark/BookMarkTitleViewHolder.java

@@ -0,0 +1,35 @@
+package kr.co.zumo.app.lifeplus.view.screen.my.bookmark;
+
+import android.view.View;
+import android.widget.TextView;
+
+import kr.co.zumo.app.R;
+import kr.co.zumo.app.lifeplus.bean.api.BookmarkBean;
+import kr.co.zumo.app.lifeplus.view.IEventListener;
+
+/**
+ * BookMarkTitleViewHolder
+ * <pre>
+ * </pre>
+ *
+ * @author 하세미
+ * @version 1.0
+ * @history 하세미   [2018-11-26]   [최초 작성]
+ * @since 2018-11-26
+ */
+public class BookMarkTitleViewHolder extends BookMarkListView {
+
+  private TextView textViewBookmarkCategory;
+
+  public BookMarkTitleViewHolder(View itemView) {
+    super(itemView);
+    textViewBookmarkCategory= itemView.findViewById(R.id.text_view_title);
+  }
+
+  @Override
+  public void bind(BookmarkBean bean, IEventListener listener) {
+    super.bind(bean, listener);
+    // TODO: API 미비로 북마크 정렬 안됨, 추후 개발 예정
+    textViewBookmarkCategory.setText(R.string.contents_category1_action_bar_title);
+  }
+}

+ 20 - 0
app/src/main/res/layout/book_mark_title_view.xml

@@ -0,0 +1,20 @@
+<?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="wrap_content">
+
+  <TextView
+    android:id="@+id/text_view_title"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:lineSpacingExtra="6sp"
+    android:text="@string/contents_category1_action_bar_title"
+    android:textColor="@color/C000000"
+    android:textSize="15sp"
+    app:layout_constraintBottom_toBottomOf="parent"
+    app:layout_constraintStart_toStartOf="parent"
+    app:layout_constraintTop_toTopOf="parent"/>
+</android.support.constraint.ConstraintLayout>

+ 21 - 30
app/src/main/res/layout/fragment_book_mark_list.xml

@@ -21,29 +21,43 @@
 
       <kr.co.zumo.app.lifeplus.view.custom.CustomSpinner
         android:id="@+id/spinner_book_mark"
-        android:layout_width="0dp"
+        android:layout_width="wrap_content"
         android:layout_height="45dp"
+        android:layout_gravity="end"
         android:layout_marginTop="23dp"
         android:layout_marginEnd="25dp"
+        android:layout_marginBottom="15dp"
         android:layout_weight="2"
         android:background="@drawable/spinner_drop_down_triangle"
         android:entries="@array/book_mark_sort"
         android:focusable="true"
-        android:lineSpacingExtra="5sp"
+        android:lineSpacingExtra="3sp"
         android:paddingEnd="10dp"
         android:textColor="@color/C000000"
-        android:textSize="14sp"
+        android:textSize="12dp"
+        app:layout_collapseMode="parallax"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintTop_toTopOf="parent"/>
 
+      <android.support.v7.widget.Toolbar
+        android:id="@+id/flexible.example.toolbar"
+        android:layout_width="match_parent"
+        android:layout_height="22dp"
+        android:background="@null"
+        app:elevation="0dp"
+        android:visibility="invisible"
+        app:layout_collapseMode="pin"
+        />
+
       <android.support.constraint.ConstraintLayout
         android:id="@+id/category_layout"
+        android:background="@color/CFFFFFF"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
+        android:layout_gravity="end|bottom"
         android:layout_marginTop="15dp"
         android:layout_marginEnd="25dp"
-        app:layout_constraintEnd_toEndOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/spinner_book_mark"
+        app:layout_collapseMode="pin"
         >
 
         <TextView
@@ -158,37 +172,14 @@
 
       </android.support.constraint.ConstraintLayout>
 
-      <android.support.v7.widget.Toolbar
-        android:id="@+id/flexible.example.toolbar"
-        android:layout_width="match_parent"
-        android:layout_height="35dp"
-        android:layout_gravity="top"
-        android:background="@null"
-        android:visibility="invisible"
-        app:elevation="0dp"
-        app:layout_collapseMode="pin"
-        tools:visibility="gone"
-        />
+
     </android.support.design.widget.CollapsingToolbarLayout>
   </android.support.design.widget.AppBarLayout>
 
-  <TextView
-    android:id="@+id/text_view_title"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:layout_marginStart="25dp"
-    android:layout_marginTop="35dp"
-    android:lineSpacingExtra="6sp"
-    android:text="주말에 뭐하지"
-    android:textColor="@color/C000000"
-    android:textSize="15sp"
-    app:layout_constraintStart_toStartOf="parent"
-    app:layout_constraintTop_toBottomOf="@+id/category_layout"/>
-
   <android.support.v7.widget.RecyclerView
     android:id="@+id/recycler_view_book_mark_list"
     android:layout_width="match_parent"
-    android:layout_height="0dp"
+    android:layout_height="wrap_content"
     android:layout_marginStart="25dp"
     android:layout_marginTop="10dp"
     app:layout_behavior="@string/appbar_scrolling_view_behavior"