|
|
@@ -3,11 +3,9 @@ package kr.co.zumo.app.lifeplus.view.screen.contents;
|
|
|
import android.support.annotation.Nullable;
|
|
|
import android.util.Log;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import io.reactivex.disposables.Disposable;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.api.APIContentsLogModule;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.APIData;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.BookmarkBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.ContentsBookmarkRequestBean;
|
|
|
@@ -15,11 +13,10 @@ 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.ContentsItemBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.ContentsLikeRequestBean;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.api.ContentsLogRequestBean;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.api.ContentsLogResultBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.ItemNoRequestBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.LifeplusAPIBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.SeriesItemBean;
|
|
|
+import kr.co.zumo.app.lifeplus.helper.ContentsLogManager;
|
|
|
import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APIContentsDetailModule;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APIError;
|
|
|
@@ -28,7 +25,6 @@ import kr.co.zumo.app.lifeplus.supervisor.ContentsFlagHelper;
|
|
|
import kr.co.zumo.app.lifeplus.tool.ReviewCounter;
|
|
|
import kr.co.zumo.app.lifeplus.util.StringUtil;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
-import kr.co.zumo.app.lifeplus.view.IEventListener;
|
|
|
import kr.co.zumo.app.lifeplus.view.dialog.ShareDialog;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.my.bookmark.BookmarkManager;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.setting.MemberInfoModelHelper;
|
|
|
@@ -48,7 +44,6 @@ public class ContentsModel extends ContentsBaseModel {
|
|
|
private Disposable disposableDetail;
|
|
|
private Disposable disposableSeriesLiked;
|
|
|
private Disposable disposableSeriesBookmarked;
|
|
|
- private Disposable disposableLog;
|
|
|
private ContentsDetailListBean contentsDetailListBean;
|
|
|
private SeriesItemBean selectedSeriesItemBean;
|
|
|
private boolean canSeriesLogging = true;
|
|
|
@@ -62,6 +57,7 @@ public class ContentsModel extends ContentsBaseModel {
|
|
|
@Override
|
|
|
protected void destroyViewInternalModel() {
|
|
|
ContentsFlagHelper.getInstance().unregisterChangedObserver(hashCode);
|
|
|
+ ContentsLogManager.getInstance().remove(this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -150,11 +146,6 @@ public class ContentsModel extends ContentsBaseModel {
|
|
|
disposableSeriesLiked.dispose();
|
|
|
disposableSeriesLiked = null;
|
|
|
}
|
|
|
-
|
|
|
- if (null != disposableLog) {
|
|
|
- disposableLog.dispose();
|
|
|
- disposableLog = null;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
public ContentsDetailListBean getContentsDetailListBean() {
|
|
|
@@ -401,86 +392,30 @@ public class ContentsModel extends ContentsBaseModel {
|
|
|
return MemberInfoModelHelper.getInstance().getSpecialCode();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 로깅 초기화
|
|
|
+ */
|
|
|
+ public void initLog() {
|
|
|
+ ContentsLogManager.getInstance().of(this).initLog();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 페이지 본 것으로 로그 추가
|
|
|
*
|
|
|
* @param currentIndex
|
|
|
*/
|
|
|
public void log(int currentIndex) {
|
|
|
- if (isLogFlushed) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 초기화 됐을 때만 로깅
|
|
|
- if (null != pageNos) {
|
|
|
- ContentsItemBean bean = getItem(currentIndex);
|
|
|
- if (null != bean) {
|
|
|
- String pageNo = bean.getListItemNo();
|
|
|
- pageNos.add(pageNo);
|
|
|
- }
|
|
|
+ ContentsItemBean bean = getItem(currentIndex);
|
|
|
+ if (null != bean) {
|
|
|
+ ContentsLogManager.getInstance().of(this).log(bean);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<String> pageNos;
|
|
|
- private boolean isLogFlushed;
|
|
|
-
|
|
|
- /**
|
|
|
- * 로깅 초기화
|
|
|
- */
|
|
|
- public void initLog() {
|
|
|
- isLogFlushed = false;
|
|
|
- pageNos = new ArrayList<>();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 로그 전송
|
|
|
- *
|
|
|
- * @param listener
|
|
|
*/
|
|
|
- public void flushLog(IEventListener listener) {
|
|
|
- if (isLogFlushed) {
|
|
|
- // 1회만 로깅하기. 성공으로 리턴.
|
|
|
- listener.onEvent(new Event.Builder(Event.SUCCESS).build());
|
|
|
- return;
|
|
|
- }
|
|
|
- if (null == pageNos || pageNos.size() == 0) {
|
|
|
- // 로그 없음
|
|
|
- listener.onEvent(new Event.Builder(Event.SUCCESS).build());
|
|
|
- return;
|
|
|
- }
|
|
|
- // log 된 페이지 no 를 순서대로 정렬
|
|
|
- List<String> logNos = new ArrayList<>();
|
|
|
-
|
|
|
- List<ContentsItemBean> list = getContentsDetailListBean().getItemDetailList();
|
|
|
- if (null != list) {
|
|
|
- int len = list.size();
|
|
|
- for (int i = 0; i < len; ++i) {
|
|
|
- String listItemNo = list.get(i).getListItemNo();
|
|
|
- for (String pageNo : pageNos) {
|
|
|
- if (pageNo.equals(listItemNo)) {
|
|
|
- logNos.add(listItemNo);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ContentsLogRequestBean requestBean = new ContentsLogRequestBean(getContentsNo());
|
|
|
- requestBean.setItemNoBeans(logNos);
|
|
|
-
|
|
|
- isLogFlushed = true;
|
|
|
- disposableLog = new APIContentsLogModule().call(requestBean, new APIModuleListener<ContentsLogResultBean>(waiterCaller) {
|
|
|
- @Override
|
|
|
- public void onApiSuccess(ContentsLogResultBean resultBean) {
|
|
|
- listener.onEvent(new Event.Builder(Event.SUCCESS).build());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onApiError(String errorMessage, APIError error) {
|
|
|
- listener.onEvent(new Event.Builder(Event.ERROR).build());
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
+ public void flushLog() {
|
|
|
+ ContentsLogManager.getInstance().of(this).flushLog(getContentsDetailListBean(), getContentsNo(), e -> {});
|
|
|
}
|
|
|
|
|
|
}
|