Pārlūkot izejas kodu

Merge branch 'develop' of https://github.com/swict/LifePlusAndroid into develop

Hasemi 7 gadi atpakaļ
vecāks
revīzija
c13a316d27

+ 2 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/helper/ActionBarHelper.java

@@ -235,7 +235,7 @@ public class ActionBarHelper extends Helper {
     else if (isTransparentBackground) {
       if (isScrollable) {
         // todo 스크롤되는 경우에는 appbar behavior 도 수정 필요;
-        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP);
+        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
         appBarLayoutParams.setBehavior(new CustomHeaderBehavior());
 
         // todo 스크롤되는 경우에는 appbar behavior 도 수정 필요;
@@ -249,7 +249,7 @@ public class ActionBarHelper extends Helper {
     }
     else {
       if (isScrollable) {
-        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP);
+        params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS/* | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP*/);
         appBarLayoutParams.setBehavior(new CustomHeaderBehavior());
 
         containerLayoutParams.setBehavior(null);

+ 105 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/contents/series/CustomContentsSeriesView.java

@@ -0,0 +1,105 @@
+/*
+ * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
+ */
+package kr.co.zumo.app.lifeplus.view.custom.contents.series;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.bumptech.glide.Glide;
+
+import java.util.List;
+
+import kr.co.zumo.app.R;
+import kr.co.zumo.app.lifeplus.bean.api.SeriesItemBean;
+import kr.co.zumo.app.lifeplus.view.IEventListener;
+import kr.co.zumo.app.lifeplus.view.screen.contents.series.ContentsSeriesAdapter;
+
+/**
+ * CustomContentsSeriesView
+ * <pre>
+ * </pre>
+ *
+ * @author 민효동
+ * @version 1.0
+ * @history 민효동   [2018. 11. 30.]   [최초 작성]
+ * @since 2018. 11. 30.
+ */
+public class CustomContentsSeriesView extends FrameLayout {
+
+  private RecyclerView recyclerView;
+  private TextView textViewTitle;
+  private TextView textViewSubTitle;
+  private ContentsSeriesAdapter adapter;
+  private ImageView imageBackground;
+
+  public CustomContentsSeriesView(@NonNull Context context) {
+    super(context);
+    init(context);
+  }
+
+  public CustomContentsSeriesView(@NonNull Context context, @Nullable AttributeSet attrs) {
+    super(context, attrs);
+    init(context);
+  }
+
+  public CustomContentsSeriesView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+    super(context, attrs, defStyleAttr);
+    init(context);
+  }
+
+
+  private void init(Context context) {
+    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+    inflater.inflate(R.layout.custom_contents_series, this);
+
+    textViewSubTitle = findViewById(R.id.text_view_sub_title);
+    textViewTitle = findViewById(R.id.text_view_title);
+    imageBackground = findViewById(R.id.image_view_series);
+
+    recyclerView = findViewById(R.id.recycler_view_series);
+  }
+
+  public void setSeriesTitle(String title) {
+    textViewTitle.setText(title);
+  }
+
+  public void setSeriesSubTitle(String subTitle) {
+    textViewSubTitle.setText(subTitle);
+  }
+
+  public void setSeriesBackgroundUrl(String url) {
+    Glide.with(imageBackground).load(url).into(imageBackground);
+  }
+
+  public void draw(List<SeriesItemBean> list, IEventListener listener) {
+    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+    adapter = new ContentsSeriesAdapter(inflater, list, event -> {
+      listener.onEvent(event);
+    });
+
+    recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
+    recyclerView.setAdapter(adapter);
+  }
+
+  public void setLiked(boolean isChecked) {
+    adapter.notifyDataSetChanged();
+  }
+
+  public void setBookmarked(boolean isChecked) {
+    adapter.notifyDataSetChanged();
+  }
+
+  public void updateContents() {
+    adapter.notifyDataSetChanged();
+  }
+}

+ 2 - 5
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/contents/series/ContentsSeriesAdapter.java

@@ -1,6 +1,5 @@
 package kr.co.zumo.app.lifeplus.view.screen.contents.series;
 
-import android.content.Context;
 import android.support.annotation.NonNull;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
@@ -26,16 +25,14 @@ import kr.co.zumo.app.lifeplus.view.IEventListener;
  */
 public class ContentsSeriesAdapter extends RecyclerView.Adapter<ContentsSeriesViewHolder> {
 
-  private Context context;
   private LayoutInflater inflater;
   private IEventListener listener;
   private List<SeriesItemBean> list;
 
-  public ContentsSeriesAdapter(Context context, List<SeriesItemBean> list, IEventListener listener) {
-    this.context = context;
+  public ContentsSeriesAdapter(LayoutInflater inflater, List<SeriesItemBean> list, IEventListener listener) {
     this.listener = listener;
     this.list = list;
-    this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+    this.inflater = inflater;
   }
 
   @NonNull

+ 11 - 31
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/contents/series/ContentsSeriesFragment.java

@@ -3,21 +3,16 @@ package kr.co.zumo.app.lifeplus.view.screen.contents.series;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.bumptech.glide.Glide;
 
 import java.util.List;
 
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.bean.api.SeriesItemBean;
 import kr.co.zumo.app.lifeplus.helper.ActionBarHelper;
+import kr.co.zumo.app.lifeplus.view.custom.contents.series.CustomContentsSeriesView;
 import kr.co.zumo.app.lifeplus.view.screen.FragmentBase;
 
 /**
@@ -32,26 +27,16 @@ import kr.co.zumo.app.lifeplus.view.screen.FragmentBase;
  */
 public class ContentsSeriesFragment extends FragmentBase<ContentsSeriesPresenter> implements IContentsSeriesView {
 
-  private RecyclerView recyclerViewCategoryMainSeries;
-  private TextView textViewTitle;
-  private TextView textViewSubTitle;
-  private ContentsSeriesAdapter adapter;
-  private ImageView imageBackground;
+  private CustomContentsSeriesView seriesView;
 
   @Override
   protected View onAfterCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
-    return inflater.inflate(R.layout.fragment_category_main_series, container, false);
+    return inflater.inflate(R.layout.fragment_contents_series, container, false);
   }
 
   @Override
   protected void onAfterActivityCreated(Bundle savedInstanceState) {
-
-    textViewSubTitle = findViewById(R.id.text_view_sub_title);
-    textViewTitle = findViewById(R.id.text_view_title);
-    imageBackground = findViewById(R.id.image_view_series);
-
-    recyclerViewCategoryMainSeries = findViewById(R.id.recycler_view_series);
-
+    seriesView = findViewById(R.id.contents_series);
   }
 
   @Override
@@ -70,7 +55,6 @@ public class ContentsSeriesFragment extends FragmentBase<ContentsSeriesPresenter
 
   @Override
   protected void onAfterDestroyView() {
-    Glide.with(imageBackground).clear(imageBackground);
   }
 
   @Override
@@ -94,42 +78,38 @@ public class ContentsSeriesFragment extends FragmentBase<ContentsSeriesPresenter
 
   @Override
   public void setSeriesTitle(String title) {
-    textViewTitle.setText(title);
+    seriesView.setSeriesTitle(title);
   }
 
   @Override
   public void setSeriesSubTitle(String subTitle) {
-    textViewSubTitle.setText(subTitle);
+    seriesView.setSeriesSubTitle(subTitle);
   }
 
   @Override
   public void setSeriesBackgroundUrl(String url) {
-    Glide.with(imageBackground).load(url).into(imageBackground);
+    seriesView.setSeriesBackgroundUrl(url);
   }
 
   @Override
   public void draw(List<SeriesItemBean> list) {
-
-    adapter = new ContentsSeriesAdapter(getActivity(), list, event -> {
+    seriesView.draw(list, event -> {
       presenter.onEvent(event);
     });
-
-    recyclerViewCategoryMainSeries.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
-    recyclerViewCategoryMainSeries.setAdapter(adapter);
   }
 
   @Override
   public void setLiked(boolean isChecked) {
-    adapter.notifyDataSetChanged();
+    seriesView.setLiked(isChecked);
   }
 
   @Override
   public void setBookmarked(boolean isChecked) {
-    adapter.notifyDataSetChanged();
+    seriesView.setBookmarked(isChecked);
   }
 
   @Override
   public void updateContents() {
-    adapter.notifyDataSetChanged();
+    seriesView.updateContents();
   }
 }

+ 6 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainContentsCategoryHolder.java

@@ -7,7 +7,6 @@ import android.content.Context;
 import android.os.Parcelable;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
-import android.util.Log;
 import android.view.View;
 import android.widget.TextView;
 
@@ -95,9 +94,13 @@ public class MainContentsCategoryHolder extends MainContentsHolder {
       public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
         if (null != adapter) {
           adapter.onScrolled(recyclerView, dx, dy);
-          if (index == 1 && dx > 0) {
+          /**
+           * 스크롤 시킬 조건
+           * - 1번 카테고리가 화면에서 벗어나 있을 때, (아래 쪽이 잘렸을 때)
+           */
+          if (index == 1 && dx != 0) {
 //            Log.i("APP# MainContentsCategoryHolder | onScrolled", "|" + "---------------------------------------" + dx + ", " + dy);
-            listener.onEvent(new Event.Builder(Event.SCROLL).build());
+//            listener.onEvent(new Event.Builder(Event.SCROLL).build());
           }
         }
       }

app/src/main/res/layout/fragment_category_main_series.xml → app/src/main/res/layout/custom_contents_series.xml


+ 13 - 0
app/src/main/res/layout/fragment_contents_series.xml

@@ -0,0 +1,13 @@
+<?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">
+
+  <kr.co.zumo.app.lifeplus.view.custom.contents.series.CustomContentsSeriesView
+    android:id="@+id/contents_series"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"/>
+</android.support.constraint.ConstraintLayout>