|
|
@@ -6,6 +6,7 @@ package kr.co.zumo.app.lifeplus.view.screen.category;
|
|
|
import android.support.annotation.CallSuper;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
import io.reactivex.disposables.Disposable;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.CategoryBannerBean;
|
|
|
@@ -15,10 +16,15 @@ import kr.co.zumo.app.lifeplus.bean.api.CategoryContentsResultBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.CategoryRecommendBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.CategoryRecommendResultBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.CategoryRequestBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.ContentsDetailListBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.ContentsDetailResultBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.LifeplusContentsBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.StringRequestBean;
|
|
|
import kr.co.zumo.app.lifeplus.model.Model;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APICategoryBannerLoadModule;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APICategoryContentsLoadModule;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APICategoryRecommendLoadModule;
|
|
|
+import kr.co.zumo.app.lifeplus.model.module.APIContentsDetailModule;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.IAPIModuleListener;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
|
|
|
@@ -37,6 +43,7 @@ public abstract class CategoryMainModel extends Model {
|
|
|
public static final int LOADED_RECOMMEND = 0;
|
|
|
public static final int LOADED_BANNER = 1;
|
|
|
public static final int LOADED_CONTENTS = 2;
|
|
|
+ public static final int LOADED_DETAIL = 3;
|
|
|
|
|
|
private Disposable disposableBanner;
|
|
|
private Disposable disposableContents;
|
|
|
@@ -44,10 +51,14 @@ public abstract class CategoryMainModel extends Model {
|
|
|
private ArrayList<CategoryBannerBean> bannerBeans;
|
|
|
private ArrayList<CategoryRecommendBean> recommendBeans;
|
|
|
private ArrayList<CategoryContentsBean> contentsBeans;
|
|
|
+ private Disposable disposableDetail;
|
|
|
+ private ContentsDetailListBean contentsDetailListBean;
|
|
|
|
|
|
@APICategoryContentsLoadModule.Order
|
|
|
private int currentOrder = APICategoryContentsLoadModule.ORDER_BY_LATEST;
|
|
|
|
|
|
+ private int selectedRecommendedIndex;
|
|
|
+
|
|
|
@Override
|
|
|
protected void createViewInternal() {
|
|
|
}
|
|
|
@@ -204,5 +215,42 @@ public abstract class CategoryMainModel extends Model {
|
|
|
return contentsBeans;
|
|
|
}
|
|
|
|
|
|
- protected abstract void modifyContents(ArrayList<CategoryContentsBean> contentsBeans);
|
|
|
+ public void loadDetail(String itemNumber) {
|
|
|
+ disposableDetail = new APIContentsDetailModule().call(new StringRequestBean(itemNumber), new IAPIModuleListener<ContentsDetailResultBean>() {
|
|
|
+ @Override
|
|
|
+ public void onApiSuccess(ContentsDetailResultBean resultBean) {
|
|
|
+ contentsDetailListBean = resultBean.getData();
|
|
|
+
|
|
|
+ onResult(new Event.Builder(Event.SUCCESS).index(LOADED_DETAIL).build());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onApiReason(ContentsDetailResultBean resultBean) {
|
|
|
+ onResult(new Event.Builder(Event.ERROR).string(resultBean.getReturnMessage()).build());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onApiError(String errorMessage) {
|
|
|
+ onResult(new Event.Builder(Event.ERROR).string(errorMessage).build());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public ContentsDetailListBean getContentsDetailListBean() {
|
|
|
+ return contentsDetailListBean;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected abstract void modifyContents(List<CategoryContentsBean> contentsBeans);
|
|
|
+
|
|
|
+ public int getSelectedRecommendedIndex() {
|
|
|
+ return selectedRecommendedIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSelectedRecommendedIndex(int selectedRecommendedIndex) {
|
|
|
+ this.selectedRecommendedIndex = selectedRecommendedIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ public LifeplusContentsBean getSelectedRecommendBean() {
|
|
|
+ return recommendBeans.get(selectedRecommendedIndex);
|
|
|
+ }
|
|
|
}
|