|
|
@@ -0,0 +1,69 @@
|
|
|
+/*
|
|
|
+ * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
|
|
|
+ */
|
|
|
+package kr.co.zumo.app.lifeplus.view.command;
|
|
|
+
|
|
|
+import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
+import io.reactivex.disposables.Disposable;
|
|
|
+import io.reactivex.schedulers.Schedulers;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.UserIDBean;
|
|
|
+import kr.co.zumo.app.lifeplus.model.Model;
|
|
|
+import kr.co.zumo.app.lifeplus.network.api.LifeplusAPIService;
|
|
|
+import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
+import kr.co.zumo.app.lifeplus.view.IView;
|
|
|
+import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
|
|
|
+
|
|
|
+/**
|
|
|
+ * ExitCommand
|
|
|
+ * <pre>
|
|
|
+ * </pre>
|
|
|
+ *
|
|
|
+ * @author 민효동
|
|
|
+ * @version 1.0
|
|
|
+ * @history 민효동 [2018-09-22] [최초 작성]
|
|
|
+ * @since 2018-09-22
|
|
|
+ */
|
|
|
+public class DeleteAccountCommand extends Command<Model, IView, Presenter> {
|
|
|
+
|
|
|
+ private Disposable disposable;
|
|
|
+ private String userId;
|
|
|
+
|
|
|
+ public DeleteAccountCommand(String userId) {
|
|
|
+ this.userId = userId;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void preExecute(Model model, IView view, Presenter presenter) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void execute(Model model, IView view, Presenter presenter) {
|
|
|
+ disposable = new LifeplusAPIService().deleteMember(new UserIDBean(userId))
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(resultBean -> {
|
|
|
+ if (resultBean.isSuccess()) {
|
|
|
+ presenter.onEvent(new Event.Builder(Event.MEMBER_DELETE_COMPLETED).build());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ presenter.onEvent(new Event.Builder(Event.MEMBER_DELETE_ERROR).string(resultBean.getReturnMessage()).build());
|
|
|
+ }
|
|
|
+ }, e -> {
|
|
|
+ presenter.onEvent(new Event.Builder(Event.MEMBER_DELETE_ERROR).string(e.getLocalizedMessage()).build());
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void postExecute(Model model, IView view, Presenter presenter) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void dispose() {
|
|
|
+ if (null != disposable) {
|
|
|
+ disposable.dispose();
|
|
|
+ disposable = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|