瀏覽代碼

[메인][New] 처음 메인 진입 시 스페셜 코드 스낵바 표시 후 닫기
- 프로모션 팝업 있을 경우 표시 후 닫기

hyodong.min 6 年之前
父節點
當前提交
8ecf200215

+ 9 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainModel.java

@@ -28,6 +28,7 @@ import io.reactivex.Single;
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.disposables.Disposable;
 import io.reactivex.schedulers.Schedulers;
+import kr.co.zumo.app.lifeplus.bean.SignUpCompletedBean;
 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.MainContentsBean;
@@ -610,4 +611,12 @@ public class MainModel extends Model {
     };
   }
 
+  /**
+   * 가입 스낵바 표시 가능 여부
+   *
+   * @return
+   */
+  public boolean canDisplayNewbiePopup() {
+    return null != getDeliveryPackaging(SignUpCompletedBean.class);
+  }
 }

+ 28 - 6
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/main/MainPresenter.java

@@ -15,7 +15,6 @@ import io.reactivex.disposables.Disposable;
 import kr.co.zumo.app.R;
 import kr.co.zumo.app.lifeplus.bean.ContentsDeliveryBean;
 import kr.co.zumo.app.lifeplus.bean.EventDeliveryBean;
-import kr.co.zumo.app.lifeplus.bean.SignUpCompletedBean;
 import kr.co.zumo.app.lifeplus.bean.api.APIData;
 import kr.co.zumo.app.lifeplus.bean.api.EventDetailBean;
 import kr.co.zumo.app.lifeplus.bean.api.LinkBean;
@@ -59,6 +58,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
   private DoubleChecker doubleChecker;
   private DoubleChecker doubleCheckerPopup;
   private DoubleChecker doubleCheckerWeather;
+  private Disposable disposableNewbie;
   private boolean isRequestingLocationPermissions = false;
 
   public MainPresenter(MainModel model, IMainView view) {
@@ -99,10 +99,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
 
     model.loadWeather();
 
-    SignUpCompletedBean signUpCompletedBean = model.getDeliveryPackaging(SignUpCompletedBean.class);
-    if (null != signUpCompletedBean) {
-      model.clearDeliveryPackaging();
-
+    if (model.canDisplayNewbiePopup()) {
       // 회원 가입 팝업 표시
       showNewbiePopup();
     }
@@ -113,6 +110,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
   @Override
   protected void stopInternal() {
     clearTimer();
+    closeNewbiePopup();
   }
 
   @Override
@@ -203,6 +201,9 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
         if (event.getInteger() == Event.LOADING_WEATHER) {
           onWeatherComplete();
         }
+        else if (event.getInteger() == Event.LOADED_POPUP_INFO) {
+          startNewbiePopupTimer();
+        }
         else {
           showErrorDialog(event.getString());
         }
@@ -326,7 +327,6 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
         break;
       case Event.SPECIAL_CODE_CLICK:
         linkForNewbie(event.getEventId());
-        view.setNewbieLayoutVisible(false);
         break;
       default:
         break;
@@ -556,6 +556,8 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
   private void showPromotionPopup() {
 
     if (false == model.isVisiblePromotion() || null == model.getPromotionPopupBeans() || model.getPromotionPopupBeans().size() < 1) {
+
+      startNewbiePopupTimer();
       return;
     }
 
@@ -574,6 +576,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
         @Override
         public void onDialogResult(PromotionDialog dialog, Event event) {
           dialog.dispose();
+          startNewbiePopupTimer();
           if (event.getEventId() == Event.TODAY) {
             model.setPromotionSkipTime();
           }
@@ -586,6 +589,7 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
         @Override
         public void onDialogCanceled(PromotionDialog dialog) {
           dialog.dispose();
+          startNewbiePopupTimer();
         }
       })
       .attribute(dialog -> {
@@ -594,10 +598,28 @@ public class MainPresenter extends Presenter<MainModel, IMainView> {
       .show();
   }
 
+  private void closeNewbiePopup() {
+    if (null != disposableNewbie) {
+      disposableNewbie.dispose();
+      disposableNewbie = null;
+      view.setNewbieLayoutVisible(false);
+    }
+  }
+
   private void showNewbiePopup() {
     view.setNewbieLayoutVisible(true);
   }
 
+  private void startNewbiePopupTimer() {
+    if (model.canDisplayNewbiePopup()) {
+      disposableNewbie = Completable.timer(10000, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
+        .subscribe(() -> {
+          disposableNewbie = null;
+          view.setNewbieLayoutVisible(false);
+        });
+    }
+  }
+
   /**
    * GA 에 이용되는 현재 화면의 이름
    * - 기본값: NavigationBar 의 title