|
|
@@ -7,18 +7,21 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import io.reactivex.disposables.Disposable;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.APIData;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.LifeplusAPIBean;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.api.MemberPolicyRequestBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.MemberPushAgreeRequestBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.PolicyBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.PolicyListResultBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.PolicyNoRequestBean;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.api.PolicyNumberBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.PolicyResultBean;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.RequestBean;
|
|
|
import kr.co.zumo.app.lifeplus.bean.api.UserNameRequestBean;
|
|
|
import kr.co.zumo.app.lifeplus.model.Model;
|
|
|
import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APIError;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APILogoutModule;
|
|
|
-import kr.co.zumo.app.lifeplus.model.module.APIMemberPolicyUpdateModule;
|
|
|
+import kr.co.zumo.app.lifeplus.model.module.APIMemberPolicyLoadModule;
|
|
|
+import kr.co.zumo.app.lifeplus.model.module.APIMemberPushUpdateModule;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APIModuleListener;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APIPolicyDetailModule;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APIRenameModule;
|
|
|
@@ -26,6 +29,7 @@ import kr.co.zumo.app.lifeplus.model.verify.Verifier;
|
|
|
import kr.co.zumo.app.lifeplus.util.StringUtil;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.setting.MemberInfoModelHelper;
|
|
|
+import kr.co.zumo.app.lifeplus.view.screen.setting.SettingViewHolder;
|
|
|
import kr.co.zumo.app.lifeplus.zumo.bean.api.MemberInfoBean;
|
|
|
import kr.co.zumo.app.lifeplus.zumo.bean.api.MemberInfoResultBean;
|
|
|
|
|
|
@@ -170,7 +174,7 @@ public class SettingMemberInfoModel extends Model {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 스페셜 코드 검증
|
|
|
+ * 이름 검증
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -206,151 +210,74 @@ public class SettingMemberInfoModel extends Model {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 선택 약관 전체 동의
|
|
|
+ * 선택 약관 하나 동의
|
|
|
*
|
|
|
+ * @param index
|
|
|
* @param isChecked
|
|
|
*/
|
|
|
- public void updatePolicyAll(boolean isChecked) {
|
|
|
- if (null == memberInfoBean || null == memberInfoBean.getInfoAgreeList()) {
|
|
|
- onResult(new Event.Builder(Event.ERROR).integer(Event.MEMBER_UPDATE_POLICY_ALL).bool(isChecked).string("").build());
|
|
|
- return;
|
|
|
- }
|
|
|
- backupChecked();
|
|
|
- setCheckAll(isChecked);
|
|
|
-
|
|
|
- List<PolicyBean> policyBeans = memberInfoBean.getInfoAgreeList();
|
|
|
-
|
|
|
- List<PolicyNumberBean> list = new ArrayList<>();
|
|
|
+ public void updatePolicyAt(int index, boolean isChecked) {
|
|
|
+ PolicyBean bean = getPolicyList().get(index);
|
|
|
+ bean.setChecked(isChecked);
|
|
|
|
|
|
- for (PolicyBean bean : policyBeans) {
|
|
|
- list.add(new PolicyNumberBean(bean.getPolicyNumber(), isChecked));
|
|
|
- }
|
|
|
+ setPushEventEnabledInternal(isChecked);
|
|
|
+ MemberPushAgreeRequestBean pushBean = getPushBean("", APIData.valueOf(isChecked), "");
|
|
|
|
|
|
- disposablePolicy = new APIMemberPolicyUpdateModule().call(new MemberPolicyRequestBean(getUserName(), list), new APIModuleListener<LifeplusAPIBean>(waiterCaller) {
|
|
|
+ disposablePolicy = new APIMemberPushUpdateModule().call(pushBean, new APIModuleListener<LifeplusAPIBean>(waiterCaller) {
|
|
|
@Override
|
|
|
public void onApiSuccess(LifeplusAPIBean resultBean) {
|
|
|
-
|
|
|
- onResult(new Event.Builder(Event.RESULT).integer(Event.MEMBER_UPDATE_POLICY_ALL).build());
|
|
|
+ onResult(new Event.Builder(Event.RESULT).integer(Event.MEMBER_UPDATE_POLICY).build());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onApiError(String errorMessage, APIError error) {
|
|
|
- restoreChecked();
|
|
|
- onResult(new Event.Builder(Event.ERROR).integer(Event.MEMBER_UPDATE_POLICY_ALL).bool(isChecked).string(errorMessage).build());
|
|
|
-
|
|
|
+ bean.setChecked(!isChecked);
|
|
|
+ setPushEventEnabledInternal(!isChecked);
|
|
|
+ onResult(new Event.Builder(Event.ERROR).integer(SettingViewHolder.SWITCH_MARKETING).bool(isChecked).string(errorMessage).build());
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 전체 동의 실패 시 이전 상태 (예> Y, N, Y 등)으로 되돌리기 위해 현재 상태 저장
|
|
|
+ * 푸쉬 마케팅 알림 설정
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<Boolean> getBackupChecked() {
|
|
|
- return backups;
|
|
|
+ public boolean isPushEventEnabled() {
|
|
|
+ return SuperModel.getInstance().getPreferences().isPushEventEnabled();
|
|
|
}
|
|
|
|
|
|
- private void restoreChecked() {
|
|
|
- if (null == backups) {
|
|
|
- return;
|
|
|
- }
|
|
|
- List<PolicyBean> beans = memberInfoBean.getInfoAgreeList();
|
|
|
- int len = backups.size();
|
|
|
-
|
|
|
- for (int i = 0; i < len; ++i) {
|
|
|
- PolicyBean bean = beans.get(i);
|
|
|
- bean.setChecked(backups.get(i));
|
|
|
- }
|
|
|
-
|
|
|
+ private void setPushEventEnabledInternal(boolean isEnabled) {
|
|
|
+ SuperModel.getInstance().getPreferences().setPushEventEnabled(isEnabled);
|
|
|
}
|
|
|
|
|
|
- private void backupChecked() {
|
|
|
- backups = new ArrayList<>();
|
|
|
- List<PolicyBean> beans = memberInfoBean.getInfoAgreeList();
|
|
|
- int len = beans.size();
|
|
|
- for (int i = 0; i < len; ++i) {
|
|
|
- PolicyBean bean = beans.get(i);
|
|
|
- backups.add(bean.isChecked());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void setCheckAll(boolean isChecked) {
|
|
|
- List<PolicyBean> beans = memberInfoBean.getInfoAgreeList();
|
|
|
- for (PolicyBean bean : beans) {
|
|
|
- bean.setChecked(isChecked);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 선택 약관 하나 동의
|
|
|
- *
|
|
|
- * @param index
|
|
|
- * @param isChecked
|
|
|
- */
|
|
|
- public void updatePolicyAt(int index, boolean isChecked) {
|
|
|
- if (null == memberInfoBean || null == memberInfoBean.getInfoAgreeList()) {
|
|
|
- onResult(new Event.Builder(Event.ERROR).integer(Event.MEMBER_UPDATE_POLICY).index(index).bool(isChecked).string("").build());
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- PolicyBean bean = memberInfoBean.getInfoAgreeList().get(index);
|
|
|
- if (null == bean) {
|
|
|
- onResult(new Event.Builder(Event.ERROR).integer(Event.MEMBER_UPDATE_POLICY).index(index).bool(isChecked).string("").build());
|
|
|
- return;
|
|
|
- }
|
|
|
- bean.setChecked(isChecked);
|
|
|
- List<PolicyNumberBean> list = new ArrayList<>();
|
|
|
- list.add(new PolicyNumberBean(bean.getPolicyNumber(), isChecked));
|
|
|
-
|
|
|
- disposablePolicy = new APIMemberPolicyUpdateModule().call(new MemberPolicyRequestBean(getUserName(), list), new APIModuleListener<LifeplusAPIBean>(waiterCaller) {
|
|
|
- @Override
|
|
|
- public void onApiSuccess(LifeplusAPIBean resultBean) {
|
|
|
- onResult(new Event.Builder(Event.RESULT).integer(Event.MEMBER_UPDATE_POLICY).build());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onApiError(String errorMessage, APIError error) {
|
|
|
- bean.setChecked(!isChecked);
|
|
|
- onResult(new Event.Builder(Event.ERROR).integer(Event.MEMBER_UPDATE_POLICY).index(index).bool(isChecked).string(errorMessage).build());
|
|
|
- }
|
|
|
- });
|
|
|
+ private MemberPushAgreeRequestBean getPushBean(String push, String marketing, String location) {
|
|
|
+ MemberPushAgreeRequestBean bean = new MemberPushAgreeRequestBean(getUserName());
|
|
|
+ bean.setPushEnabled(push);
|
|
|
+ bean.setPushMarketingEnabled(marketing);
|
|
|
+ bean.setLocationServiceEnabled(location);
|
|
|
+ return bean;
|
|
|
}
|
|
|
|
|
|
public void loadTerms(int index) {
|
|
|
- disposablePolicy = new APIPolicyDetailModule().call(new PolicyNoRequestBean(memberInfoBean.getInfoAgreeList().get(index).getPolicyNumber()), new APIModuleListener<PolicyResultBean>(waiterCaller) {
|
|
|
+ disposablePolicy = new APIPolicyDetailModule().call(new PolicyNoRequestBean(getPolicyList().get(index).getPolicyNumber()), new APIModuleListener<PolicyResultBean>(waiterCaller) {
|
|
|
@Override
|
|
|
public void onApiSuccess(PolicyResultBean resultBean) {
|
|
|
if (null != resultBean.getData()) {
|
|
|
- onResult(new Event.Builder(Event.RESULT).index(Event.POLICY_DETAIL).string(resultBean.getData().getContents()).build());
|
|
|
+ onResult(new Event.Builder(Event.RESULT).integer(Event.POLICY_DETAIL).string(resultBean.getData().getContents()).build());
|
|
|
}
|
|
|
else {
|
|
|
- onResult(new Event.Builder(Event.ERROR).index(Event.POLICY_DETAIL).string("loading error...").build());
|
|
|
+ onResult(new Event.Builder(Event.ERROR).integer(Event.POLICY_DETAIL).string("loading error...").build());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onApiError(String errorMessage, APIError error) {
|
|
|
- onResult(new Event.Builder(Event.ERROR).index(Event.POLICY_DETAIL).string(errorMessage).build());
|
|
|
+ onResult(new Event.Builder(Event.ERROR).integer(Event.POLICY_DETAIL).string(errorMessage).build());
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 마케팅 약관 동의 항목이 체크 됐는지 확인
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- public boolean isMarketingEnabled() {
|
|
|
- for (PolicyBean policyBean : memberInfoBean.getInfoAgreeList()) {
|
|
|
- if (PolicyBean.UID_MARKETING.equals(policyBean.getUid())) {
|
|
|
- return policyBean.isChecked();
|
|
|
- }
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
private void stopLogout() {
|
|
|
if (null != disposableLogout) {
|
|
|
disposableLogout.dispose();
|
|
|
@@ -379,4 +306,37 @@ public class SettingMemberInfoModel extends Model {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ private List<PolicyBean> policyList;
|
|
|
+ private String MARKETING_KEY = "마케팅";
|
|
|
+
|
|
|
+ public void loadPolicyList() {
|
|
|
+ disposablePolicy = new APIMemberPolicyLoadModule().call(new RequestBean(), new APIModuleListener<PolicyListResultBean>(waiterCaller) {
|
|
|
+ @Override
|
|
|
+ public void onApiSuccess(PolicyListResultBean resultBean) {
|
|
|
+ List<PolicyBean> agreeItems = resultBean.getData();
|
|
|
+
|
|
|
+ policyList = new ArrayList<>();
|
|
|
+ for (PolicyBean agreeItem : agreeItems) {
|
|
|
+ if (null != agreeItem && null != agreeItem.getTitle() && agreeItem.getTitle().contains(MARKETING_KEY)) {
|
|
|
+ agreeItem.setTitle("이벤트 및 프로모션 메일 수신");
|
|
|
+ agreeItem.setChecked(isPushEventEnabled());
|
|
|
+ policyList.add(agreeItem);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onResult(new Event.Builder(Event.RESULT).integer(Event.POLICY_REQUEST).build());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onApiError(String errorMessage, APIError error) {
|
|
|
+ onResult(new Event.Builder(Event.ERROR).integer(Event.POLICY_REQUEST).string(errorMessage).build());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<PolicyBean> getPolicyList() {
|
|
|
+ return policyList;
|
|
|
+ }
|
|
|
}
|