|
@@ -6,6 +6,7 @@ package kr.co.zumo.app.lifeplus.model;
|
|
|
import android.arch.lifecycle.ViewModel;
|
|
import android.arch.lifecycle.ViewModel;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
@@ -17,7 +18,10 @@ import kr.co.zumo.app.lifeplus.application.App;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.BookmarkListResultBean;
|
|
import kr.co.zumo.app.lifeplus.bean.api.BookmarkListResultBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.BucketListRequestBean;
|
|
import kr.co.zumo.app.lifeplus.bean.api.BucketListRequestBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.BucketListResultBean;
|
|
import kr.co.zumo.app.lifeplus.bean.api.BucketListResultBean;
|
|
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.NoticeBean;
|
|
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.NoticeResultBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.PageRequestBean;
|
|
import kr.co.zumo.app.lifeplus.bean.api.PageRequestBean;
|
|
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.RequestBean;
|
|
|
import kr.co.zumo.app.lifeplus.helper.DeliveryHelper;
|
|
import kr.co.zumo.app.lifeplus.helper.DeliveryHelper;
|
|
|
import kr.co.zumo.app.lifeplus.helper.DeliveryResultHelper;
|
|
import kr.co.zumo.app.lifeplus.helper.DeliveryResultHelper;
|
|
|
import kr.co.zumo.app.lifeplus.helper.Helper;
|
|
import kr.co.zumo.app.lifeplus.helper.Helper;
|
|
@@ -25,6 +29,7 @@ import kr.co.zumo.app.lifeplus.helper.IHelperProvider;
|
|
|
import kr.co.zumo.app.lifeplus.helper.ScreenIDDeliveryHelper;
|
|
import kr.co.zumo.app.lifeplus.helper.ScreenIDDeliveryHelper;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APIError;
|
|
import kr.co.zumo.app.lifeplus.model.module.APIError;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APIModuleListener;
|
|
import kr.co.zumo.app.lifeplus.model.module.APIModuleListener;
|
|
|
|
|
+import kr.co.zumo.app.lifeplus.model.module.APINoticeModule;
|
|
|
import kr.co.zumo.app.lifeplus.network.INetworkReceiverListener;
|
|
import kr.co.zumo.app.lifeplus.network.INetworkReceiverListener;
|
|
|
import kr.co.zumo.app.lifeplus.network.NetworkWatcher;
|
|
import kr.co.zumo.app.lifeplus.network.NetworkWatcher;
|
|
|
import kr.co.zumo.app.lifeplus.util.StringUtil;
|
|
import kr.co.zumo.app.lifeplus.util.StringUtil;
|
|
@@ -55,6 +60,7 @@ public abstract class Model extends ViewModel implements ILifeCycle, IHelperProv
|
|
|
protected IWaiterCallable waiterCaller;
|
|
protected IWaiterCallable waiterCaller;
|
|
|
private Disposable disposableBucket;
|
|
private Disposable disposableBucket;
|
|
|
private Disposable disposableBookMarkList;
|
|
private Disposable disposableBookMarkList;
|
|
|
|
|
+ private Disposable disposableNoti;
|
|
|
private int screenId;
|
|
private int screenId;
|
|
|
private int prevScreenId;
|
|
private int prevScreenId;
|
|
|
|
|
|
|
@@ -341,6 +347,44 @@ public abstract class Model extends ViewModel implements ILifeCycle, IHelperProv
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 최신 알림이 있는지 파악
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param listener
|
|
|
|
|
+ */
|
|
|
|
|
+ public void loadNotiLatest(IEventListener listener) {
|
|
|
|
|
+ disposableNoti =
|
|
|
|
|
+ new APINoticeModule().call(new RequestBean(), new APIModuleListener<NoticeResultBean>(waiterCaller) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onApiSuccess(NoticeResultBean resultBean) {
|
|
|
|
|
+ List<NoticeBean> noticeBeans = resultBean.getData();
|
|
|
|
|
+
|
|
|
|
|
+ if (null != noticeBeans && noticeBeans.size() > 0) {
|
|
|
|
|
+ // 마지막 시간과 비교해서 다르면 뉴 표시
|
|
|
|
|
+
|
|
|
|
|
+ Log.d("APP# Model | onApiSuccess, 369", "|" + noticeBeans.get(0).getOpeningDate());
|
|
|
|
|
+ if (SuperModel.getInstance().getPreferences().getNotiLatestTime().equals(noticeBeans.get(0).getOpeningDate())) {
|
|
|
|
|
+ // 새 알림 없음.
|
|
|
|
|
+ listener.onEvent(new Event.Builder(Event.SUCCESS).bool(false).build());
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ // 새 알림 있음.
|
|
|
|
|
+ listener.onEvent(new Event.Builder(Event.SUCCESS).bool(true).build());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ onApiError("", new APIError(APIError.ERROR_REASON));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onApiError(String errorMessage, APIError error) {
|
|
|
|
|
+ listener.onEvent(new Event.Builder(Event.ERROR).bool(false).build());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 현 Screen ID 저장
|
|
* 현 Screen ID 저장
|
|
|
*
|
|
*
|