|
|
@@ -1,19 +1,8 @@
|
|
|
package kr.co.zumo.app.lifeplus.view.screen.category.type1;
|
|
|
|
|
|
-import android.os.Bundle;
|
|
|
-import android.support.annotation.NonNull;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
-import android.support.design.widget.AppBarLayout;
|
|
|
-import android.support.design.widget.CoordinatorLayout;
|
|
|
import android.support.v7.widget.GridLayoutManager;
|
|
|
-import android.support.v7.widget.RecyclerView;
|
|
|
-import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
-import android.widget.AdapterView;
|
|
|
-import android.widget.Spinner;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
import kr.co.zumo.app.R;
|
|
|
@@ -25,10 +14,9 @@ import kr.co.zumo.app.lifeplus.util.ResourceUtil;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
import kr.co.zumo.app.lifeplus.view.custom.category.series.IMainSeriesContract;
|
|
|
import kr.co.zumo.app.lifeplus.view.custom.category.series.MainSeriesPresenter;
|
|
|
-import kr.co.zumo.app.lifeplus.view.custom.category.series.MainSeriesView;
|
|
|
-import kr.co.zumo.app.lifeplus.view.screen.FragmentBase;
|
|
|
+import kr.co.zumo.app.lifeplus.view.screen.category.CategoryID;
|
|
|
+import kr.co.zumo.app.lifeplus.view.screen.category.CategoryMainFragment;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.category.CategorySortScroller;
|
|
|
-import kr.co.zumo.app.lifeplus.view.screen.category.FocusArrayAdapter;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.category.GridItemDecoration;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.category.IFirstCategoryMainView;
|
|
|
|
|
|
@@ -42,37 +30,11 @@ import kr.co.zumo.app.lifeplus.view.screen.category.IFirstCategoryMainView;
|
|
|
* @history 하세미 [2018-10-22] [최초 작성]
|
|
|
* @since 2018-10-22
|
|
|
*/
|
|
|
-public class FirstCategoryMainFragment extends FragmentBase<FirstCategoryMainPresenter> implements IFirstCategoryMainView {
|
|
|
+public class FirstCategoryMainFragment extends CategoryMainFragment<FirstCategoryMainPresenter> implements IFirstCategoryMainView {
|
|
|
|
|
|
- private CoordinatorLayout layoutRoot;
|
|
|
- private AppBarLayout appBarLayout;
|
|
|
- private MainSeriesView mainSeriesView;
|
|
|
- private RecyclerView recyclerViewFirstCategoryMain;
|
|
|
- private View viewFilter;
|
|
|
private IMainSeriesContract.Presenter seriesPresenter;
|
|
|
- private Spinner spinnerOrder;
|
|
|
private FirstCategoryMainAdapter adapter;
|
|
|
- private FocusArrayAdapter arrayAdapter;
|
|
|
-
|
|
|
- @Nullable
|
|
|
- @Override
|
|
|
- protected View onAfterCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
- return inflater.inflate(R.layout.fragment_category_main_first, container, false);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onAfterActivityCreated(Bundle savedInstanceState) {
|
|
|
- layoutRoot = findViewById(R.id.root_layout);
|
|
|
- appBarLayout = findViewById(R.id.app_bar_layout);
|
|
|
- mainSeriesView = findViewById(R.id.series_image_text_view);
|
|
|
- recyclerViewFirstCategoryMain = findViewById(R.id.recycler_view_first_category_main);
|
|
|
- recyclerViewFirstCategoryMain.addItemDecoration(new GridItemDecoration(getActivity(), ResourceUtil.dpToPx(4),ResourceUtil.dpToPx(4),ResourceUtil.dpToPx(4),ResourceUtil.dpToPx(4)));
|
|
|
- viewFilter = findViewById(R.id.first_category_main_filter);
|
|
|
- spinnerOrder = findViewById(R.id.spinner_select_contents);
|
|
|
- List<String> spinnerList = Arrays.asList(ResourceUtil.getStringArray("main_filter"));
|
|
|
- arrayAdapter = new FocusArrayAdapter(getActivity(), R.layout.custom_spinner, spinnerList);
|
|
|
- spinnerOrder.setAdapter(arrayAdapter);
|
|
|
- }
|
|
|
+ private GridLayoutManager gridLayoutManager;
|
|
|
|
|
|
@Override
|
|
|
protected void defineActionBar(ActionBarHelper actionBarHelper) {
|
|
|
@@ -95,7 +57,7 @@ public class FirstCategoryMainFragment extends FragmentBase<FirstCategoryMainPre
|
|
|
spinnerOrder.setOnItemSelectedListener(null);
|
|
|
spinnerOrder = null;
|
|
|
}
|
|
|
- recyclerViewFirstCategoryMain = null;
|
|
|
+ recyclerView = null;
|
|
|
mainSeriesView = null;
|
|
|
if (null != viewFilter) {
|
|
|
viewFilter.setOnClickListener(null);
|
|
|
@@ -118,13 +80,13 @@ public class FirstCategoryMainFragment extends FragmentBase<FirstCategoryMainPre
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void drawContentsBanner(List<CategoryBannerBean> bannerBeans, List<CategoryContentsBean> contentsBeans) {
|
|
|
-
|
|
|
- adapter = new FirstCategoryMainAdapter(getActivity(), bannerBeans, contentsBeans, (Event event) -> {
|
|
|
- presenter.onEvent(event);
|
|
|
- });
|
|
|
+ protected String getCategoryNumber() {
|
|
|
+ return CategoryID.CATEGORY_1;
|
|
|
+ }
|
|
|
|
|
|
- GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 2);
|
|
|
+ @Override
|
|
|
+ protected void addItemDecoration() {
|
|
|
+ gridLayoutManager = new GridLayoutManager(getActivity(), 2);
|
|
|
gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
|
|
@Override
|
|
|
public int getSpanSize(int position) {
|
|
|
@@ -141,23 +103,20 @@ public class FirstCategoryMainFragment extends FragmentBase<FirstCategoryMainPre
|
|
|
return 0;
|
|
|
}
|
|
|
});
|
|
|
- recyclerViewFirstCategoryMain.setLayoutManager(gridLayoutManager);
|
|
|
- recyclerViewFirstCategoryMain.setAdapter(adapter);
|
|
|
+ recyclerView.setLayoutManager(gridLayoutManager);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void drawContentsBanner(List<CategoryBannerBean> bannerBeans, List<CategoryContentsBean> contentsBeans) {
|
|
|
|
|
|
- viewFilter.setOnClickListener(view -> {
|
|
|
- presenter.onEvent(new Event.Builder(Event.FILTER).build());
|
|
|
+ adapter = new FirstCategoryMainAdapter(getActivity(), bannerBeans, contentsBeans, (Event event) -> {
|
|
|
+ presenter.onEvent(event);
|
|
|
});
|
|
|
|
|
|
- spinnerOrder.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
- @Override
|
|
|
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- arrayAdapter.setSelectedIndex(position);
|
|
|
- presenter.onEvent(new Event.Builder(Event.ORDER).index(position).build());
|
|
|
- }
|
|
|
+ recyclerView.setPadding(ResourceUtil.dpToPx(21), 0, ResourceUtil.dpToPx(21), 0);
|
|
|
+ recyclerView.addItemDecoration(new GridItemDecoration(getActivity(), ResourceUtil.dpToPx(4), ResourceUtil.dpToPx(4), ResourceUtil.dpToPx(4), ResourceUtil.dpToPx(4)));
|
|
|
+ recyclerView.setAdapter(adapter);
|
|
|
|
|
|
- @Override
|
|
|
- public void onNothingSelected(AdapterView<?> parent) {}
|
|
|
- });
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -172,8 +131,7 @@ public class FirstCategoryMainFragment extends FragmentBase<FirstCategoryMainPre
|
|
|
@Override
|
|
|
public void updateContents(List<CategoryContentsBean> contentsBeans) {
|
|
|
adapter.update(contentsBeans);
|
|
|
- recyclerViewFirstCategoryMain.scrollToPosition(0);
|
|
|
-
|
|
|
+ recyclerView.scrollToPosition(0);
|
|
|
CategorySortScroller scroller = new CategorySortScroller(layoutRoot, appBarLayout);
|
|
|
scroller.doAppBarLayoutInitialization();
|
|
|
|
|
|
@@ -181,8 +139,7 @@ public class FirstCategoryMainFragment extends FragmentBase<FirstCategoryMainPre
|
|
|
|
|
|
@Override
|
|
|
public void hideRecommendArea() {
|
|
|
+ space.setVisibility(View.VISIBLE);
|
|
|
mainSeriesView.setVisibility(View.GONE);
|
|
|
- // TODO: 추후개발 예정
|
|
|
- recyclerViewFirstCategoryMain.setPadding(0,ResourceUtil.dpToPx(19), 0,0);
|
|
|
}
|
|
|
}
|