|
|
@@ -1,7 +1,20 @@
|
|
|
package kr.co.zumo.app.lifeplus.view.screen.contents;
|
|
|
|
|
|
+import kr.co.zumo.app.R;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.ContentsDeliveryBean;
|
|
|
+import kr.co.zumo.app.lifeplus.helper.DeliveryHelper;
|
|
|
+import kr.co.zumo.app.lifeplus.helper.NavigationBar;
|
|
|
+import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
|
|
|
+import kr.co.zumo.app.lifeplus.util.ResourceUtil;
|
|
|
+import kr.co.zumo.app.lifeplus.view.DoubleChecker;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
-import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
|
|
|
+import kr.co.zumo.app.lifeplus.view.dialog.AppReviewDialog;
|
|
|
+import kr.co.zumo.app.lifeplus.view.dialog.ConfirmDialog;
|
|
|
+import kr.co.zumo.app.lifeplus.view.dialog.DialogBuilder;
|
|
|
+import kr.co.zumo.app.lifeplus.view.dialog.DialogID;
|
|
|
+import kr.co.zumo.app.lifeplus.view.dialog.ICustomConfirmListener;
|
|
|
+import kr.co.zumo.app.lifeplus.view.dialog.ICustomDialogListener;
|
|
|
+import kr.co.zumo.app.lifeplus.view.dialog.TooltipDialog;
|
|
|
|
|
|
/**
|
|
|
* ContentsDetailPresenter
|
|
|
@@ -13,11 +26,20 @@ import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
|
|
|
* @history 하세미 [2018-11-27] [최초 작성]
|
|
|
* @since 2018-11-27
|
|
|
*/
|
|
|
-public class ContentsDetailPresenter extends Presenter<ContentsDetailModel, IContentsDetailView> {
|
|
|
+public class ContentsDetailPresenter extends ContentsBasePresenter<ContentsDetailModel, IContentsDetailView> {
|
|
|
|
|
|
+ private DoubleChecker doubleChecker;
|
|
|
|
|
|
public ContentsDetailPresenter(ContentsDetailModel model, IContentsDetailView view) {
|
|
|
super(model, view);
|
|
|
+
|
|
|
+ doubleChecker = new DoubleChecker(this::render);
|
|
|
+
|
|
|
+ this.model.loadDetail();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void render() {
|
|
|
+ view.draw(model.getContentsDetailListBean());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -37,6 +59,12 @@ public class ContentsDetailPresenter extends Presenter<ContentsDetailModel, ICon
|
|
|
|
|
|
@Override
|
|
|
protected void startInternal() {
|
|
|
+ super.startInternal();
|
|
|
+
|
|
|
+ if (null != model.getContentsBean()) {
|
|
|
+ view.setLiked(model.isLiked());
|
|
|
+ view.setBookmarked(model.isBookmarked());
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -57,7 +85,8 @@ public class ContentsDetailPresenter extends Presenter<ContentsDetailModel, ICon
|
|
|
|
|
|
@Override
|
|
|
public boolean onBackPressed() {
|
|
|
- return false;
|
|
|
+ back(ScreenID.MAIN);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -68,10 +97,156 @@ public class ContentsDetailPresenter extends Presenter<ContentsDetailModel, ICon
|
|
|
@Override
|
|
|
public void onScreenReady() {
|
|
|
|
|
|
+ doubleChecker.checkFirst();
|
|
|
+
|
|
|
+ view.setLiked(model.isLiked());
|
|
|
+ view.setBookmarked(model.isBookmarked());
|
|
|
+
|
|
|
+ /**
|
|
|
+ * fixme 조건 변경 -> 5회 이상 진입 + 마지막 페이지 일 경우.
|
|
|
+ */
|
|
|
+ int count = model.getCountForReview();
|
|
|
+ if (count < 100) {
|
|
|
+ ++count;
|
|
|
+ model.setCountForReview(count);
|
|
|
+ if (count == 3) {
|
|
|
+ model.setCountForReview(100);
|
|
|
+ reviewDialog = new DialogBuilder<AppReviewDialog, ICustomDialogListener>(getFragmentManager(), DialogID.APP_REVIEW)
|
|
|
+ .listener(new ICustomDialogListener<AppReviewDialog>() {
|
|
|
+ @Override
|
|
|
+ public void onDialogResult(AppReviewDialog dialog, Event event) {
|
|
|
+ switch (event.getEventId()) {
|
|
|
+ case Event.ADD:
|
|
|
+ view.goGooglePlay();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDialogCanceled(AppReviewDialog dialog) {
|
|
|
+ dialog.dispose();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onResult(Event event) {
|
|
|
+ protected void onContentsResultInternal(Event event) {
|
|
|
+ switch (event.getEventId()) {
|
|
|
+ case Event.SUCCESS:
|
|
|
+ if (event.getIndex() == Event.LOADED_DETAIL) {
|
|
|
+ doubleChecker.checkSecond();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Event.ERROR:
|
|
|
+ if (event.getIndex() == Event.LOADED_DETAIL) {
|
|
|
+ // 다이얼로그는 parent 에서 보여줌.
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 닷닷닷 메뉴
|
|
|
+ *
|
|
|
+ * @param actionBar
|
|
|
+ */
|
|
|
+ public void onNavigationClickDotDotDot(NavigationBar actionBar) {
|
|
|
+ showTooltipDialog();
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 좋아요 클릭
|
|
|
+ *
|
|
|
+ * @param navigationBar
|
|
|
+ */
|
|
|
+ public void onNavigationClickLike(NavigationBar navigationBar) {
|
|
|
+ model.updateLiked();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 북마크 클릭
|
|
|
+ *
|
|
|
+ * @param navigationBar
|
|
|
+ */
|
|
|
+ public void onNavigationClickBookmark(NavigationBar navigationBar) {
|
|
|
+ if (model.isMember()) {
|
|
|
+ model.updateBookmarked();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ showPopupForGuest();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 공유 클릭
|
|
|
+ *
|
|
|
+ * @param navigationBar
|
|
|
+ */
|
|
|
+ public void onNavigationClickShare(NavigationBar navigationBar) {
|
|
|
+ showShareDialog();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void showPopupForGuest() {
|
|
|
+ // 비회원 가입 유도
|
|
|
+ new DialogBuilder<ConfirmDialog, ICustomConfirmListener>(getFragmentManager(), DialogID.CONFIRM)
|
|
|
+ .listener(new ICustomConfirmListener<ConfirmDialog>() {
|
|
|
+ @Override
|
|
|
+ public void onPositiveResult(ConfirmDialog dialog, Event event) {
|
|
|
+ dialog.dispose();
|
|
|
+ go(ScreenID.SIGN_UP_START);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNegativeResult(ConfirmDialog dialog, Event event) {
|
|
|
+ dialog.dispose();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDialogCanceled(ConfirmDialog dialog) {
|
|
|
+ dialog.dispose();
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .attribute(dialog -> {
|
|
|
+ dialog.setText(ResourceUtil.getString(R.string.best_bucket_guest_guide));
|
|
|
+ dialog.setPositiveButtonLabelId(R.string.member_confirm);
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void showTooltipDialog() {
|
|
|
+ new DialogBuilder<TooltipDialog, ICustomDialogListener>(getFragmentManager(), DialogID.TOOL_TIP)
|
|
|
+ .listener(new ICustomDialogListener<TooltipDialog>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDialogResult(TooltipDialog dialog, Event event) {
|
|
|
+ if (event.getEventId() == Event.OVER_VIEW) {
|
|
|
+ dialog.dispose();
|
|
|
+
|
|
|
+ DeliveryHelper deliveryHelper = getHelper(DeliveryHelper.class);
|
|
|
+ deliveryHelper.setPackaging(new ContentsDeliveryBean.Builder(model.getContentsBean()).build());
|
|
|
+
|
|
|
+ go(ScreenID.OVER_VIEW);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDialogCanceled(TooltipDialog dialog) {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .attribute(dialog -> {
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+
|
|
|
}
|