Browse Source

[이벤트][Common] 코인 팝업 드라이버 생성

Hasemi 6 years ago
parent
commit
784419e813

+ 6 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/common/CoinPopupDriver.java

@@ -57,9 +57,14 @@ public class CoinPopupDriver {
       @Override
       public void run() {
         dialog.dispose();
-        listener.onEvent(new Event.Builder(Event.EXIT).build());
+        if (dialog.isDismissed()) {
+          listener.onEvent(new Event.Builder(Event.EXIT).build());
+
+        }
       }
     }, 2000);
+
+
   }
 
 }

+ 32 - 31
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/event/EventDetailPresenter.java

@@ -1,11 +1,10 @@
 package kr.co.zumo.app.lifeplus.view.screen.event;
 
-import android.os.Handler;
-
 import kr.co.zumo.app.lifeplus.helper.ActionBarHelper;
 import kr.co.zumo.app.lifeplus.helper.NavigationBar;
 import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
 import kr.co.zumo.app.lifeplus.view.Event;
+import kr.co.zumo.app.lifeplus.view.IEventListener;
 import kr.co.zumo.app.lifeplus.view.dialog.CoinSavingDialog;
 import kr.co.zumo.app.lifeplus.view.dialog.DialogBuilder;
 import kr.co.zumo.app.lifeplus.view.dialog.DialogID;
@@ -13,6 +12,7 @@ import kr.co.zumo.app.lifeplus.view.dialog.EventNoticeDialog;
 import kr.co.zumo.app.lifeplus.view.dialog.IAttribute;
 import kr.co.zumo.app.lifeplus.view.dialog.ICustomDialogListener;
 import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
+import kr.co.zumo.app.lifeplus.view.screen.common.CoinPopupDriver;
 
 /**
  * EventDetailPresenter
@@ -27,6 +27,7 @@ import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
 public class EventDetailPresenter extends Presenter<EventDetailModel, IEventDetailView> {
 
   private CoinSavingDialog dialog;
+  private int coinPopupShowingFlag = -1;
 
   public EventDetailPresenter(EventDetailModel model, IEventDetailView view) {
     super(model, view);
@@ -85,13 +86,7 @@ public class EventDetailPresenter extends Presenter<EventDetailModel, IEventDeta
       case Event.CLICK:
         if (model.isMember()) {
           showCoinSavingDialog();
-          new Handler().postDelayed(new Runnable() {
-            @Override
-            public void run() {
-              dialog.dispose();
-              go(ScreenID.EVENT_PARTICIPATION);
-            }
-          }, 2000);
+          go(ScreenID.EVENT_PARTICIPATION);
         }
         else {
           showPopupForGuest();
@@ -107,15 +102,7 @@ public class EventDetailPresenter extends Presenter<EventDetailModel, IEventDeta
       case Event.VOTE: //투표하기 클릭
         if (model.isMember()) {
           showCoinSavingDialog();
-          new Handler().postDelayed(new Runnable() {
-            @Override
-            public void run() {
-              dialog.dispose();
-              if (event.getIndex() != 0) {
-                view.setScrollToPosition(event.getIndex() + 1);
-              }
-            }
-          }, 2000);
+          view.setScrollToPosition(event.getIndex() + 1);
         }
         else {
           showPopupForGuest();
@@ -168,22 +155,36 @@ public class EventDetailPresenter extends Presenter<EventDetailModel, IEventDeta
   }
 
   private void showCoinSavingDialog() {
-    dialog = new DialogBuilder<CoinSavingDialog, ICustomDialogListener>(getFragmentManager(), DialogID.COIN_SAVING)
-      .listener(new ICustomDialogListener<CoinSavingDialog>() {
-        @Override
-        public void onDialogResult(CoinSavingDialog dialog, Event event) {
 
+    CoinPopupDriver coinPopupDriver = new CoinPopupDriver(getFragmentManager(), new IEventListener() {
+      @Override
+      public void onEvent(Event event) {
+        if (event.getEventId() == Event.EXIT) {
+          return;
         }
+      }
+    });
+
+    coinPopupDriver.show();
+
+
+//    dialog = new DialogBuilder<CoinSavingDialog, ICustomDialogListener>(getFragmentManager(), DialogID.COIN_SAVING)
+//      .listener(new ICustomDialogListener<CoinSavingDialog>() {
+//        @Override
+//        public void onDialogResult(CoinSavingDialog dialog, Event event) {
+//
+//        }
+//
+//        @Override
+//        public void onDialogCanceled(CoinSavingDialog dialog) {
+//          dialog.dispose();
+//
+//        }
+//      })
+//      .attribute((IAttribute<CoinSavingDialog>) dialog -> {
+//      })
+//      .show();
 
-        @Override
-        public void onDialogCanceled(CoinSavingDialog dialog) {
-          dialog.dispose();
-
-        }
-      })
-      .attribute((IAttribute<CoinSavingDialog>) dialog -> {
-      })
-      .show();
   }
 
   public void onChangedPageIndex(int index) {