|
|
@@ -10,11 +10,14 @@ import java.util.ArrayList;
|
|
|
import io.reactivex.disposables.Disposable;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.CategoryBannerBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.CategoryBannerResultBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.CategoryContentsBean;
|
|
|
+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.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.IAPIModuleListener;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
@@ -31,10 +34,16 @@ import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
*/
|
|
|
public 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;
|
|
|
+
|
|
|
private Disposable disposableBanner;
|
|
|
+ private Disposable disposableContents;
|
|
|
private Disposable disposableRecommend;
|
|
|
private ArrayList<CategoryBannerBean> bannerBeans;
|
|
|
private ArrayList<CategoryRecommendBean> recommendBeans;
|
|
|
+ private ArrayList<CategoryContentsBean> contentsBeans;
|
|
|
|
|
|
@CallSuper
|
|
|
@Override
|
|
|
@@ -62,6 +71,7 @@ public class CategoryMainModel extends Model {
|
|
|
protected void pauseInternal() {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
private void disposeLoading() {
|
|
|
if (null != disposableBanner) {
|
|
|
disposableBanner.dispose();
|
|
|
@@ -71,6 +81,10 @@ public class CategoryMainModel extends Model {
|
|
|
disposableRecommend.dispose();
|
|
|
disposableRecommend = null;
|
|
|
}
|
|
|
+ if (null != disposableContents) {
|
|
|
+ disposableContents.dispose();
|
|
|
+ disposableContents = null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -80,13 +94,38 @@ public class CategoryMainModel extends Model {
|
|
|
disposeLoading();
|
|
|
}
|
|
|
|
|
|
+ public void loadRecommendContents(String categoryNumber) {
|
|
|
+ disposableRecommend = new APICategoryRecommendLoadModule().call(new CategoryRequestBean(categoryNumber), new IAPIModuleListener<CategoryRecommendResultBean>() {
|
|
|
+ @Override
|
|
|
+ public void onApiSuccess(CategoryRecommendResultBean resultBean) {
|
|
|
+ recommendBeans = resultBean.getData();
|
|
|
+
|
|
|
+ onResult(new Event.Builder(Event.SUCCESS).index(LOADED_RECOMMEND).build());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onApiReason(CategoryRecommendResultBean 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 ArrayList<CategoryRecommendBean> getRecommendBeans() {
|
|
|
+ return recommendBeans;
|
|
|
+ }
|
|
|
+
|
|
|
public void loadBanner(String categoryNumber) {
|
|
|
disposableBanner = new APICategoryBannerLoadModule().call(new CategoryRequestBean(categoryNumber), new IAPIModuleListener<CategoryBannerResultBean>() {
|
|
|
@Override
|
|
|
public void onApiSuccess(CategoryBannerResultBean resultBean) {
|
|
|
bannerBeans = resultBean.getData();
|
|
|
|
|
|
- onResult(new Event.Builder(Event.SUCCESS).build());
|
|
|
+ onResult(new Event.Builder(Event.SUCCESS).index(LOADED_BANNER).build());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -106,17 +145,17 @@ public class CategoryMainModel extends Model {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void loadRecommendContents(String categoryNumber) {
|
|
|
- disposableRecommend = new APICategoryRecommendLoadModule().call(new CategoryRequestBean(categoryNumber), new IAPIModuleListener<CategoryRecommendResultBean>() {
|
|
|
+ public void loadContents(String categoryNumber) {
|
|
|
+ disposableContents = new APICategoryContentsLoadModule().call(new CategoryRequestBean(categoryNumber), new IAPIModuleListener<CategoryContentsResultBean>() {
|
|
|
@Override
|
|
|
- public void onApiSuccess(CategoryRecommendResultBean resultBean) {
|
|
|
- recommendBeans = resultBean.getData();
|
|
|
+ public void onApiSuccess(CategoryContentsResultBean resultBean) {
|
|
|
+ contentsBeans = resultBean.getData();
|
|
|
|
|
|
- onResult(new Event.Builder(Event.SUCCESS).build());
|
|
|
+ onResult(new Event.Builder(Event.SUCCESS).index(LOADED_CONTENTS).build());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onApiReason(CategoryRecommendResultBean resultBean) {
|
|
|
+ public void onApiReason(CategoryContentsResultBean resultBean) {
|
|
|
onResult(new Event.Builder(Event.ERROR).string(resultBean.getReturnMessage()).build());
|
|
|
}
|
|
|
|
|
|
@@ -127,7 +166,7 @@ public class CategoryMainModel extends Model {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public ArrayList<CategoryRecommendBean> getRecommendBeans() {
|
|
|
- return recommendBeans;
|
|
|
+ public ArrayList<CategoryContentsBean> getContents() {
|
|
|
+ return contentsBeans;
|
|
|
}
|
|
|
}
|