|
|
@@ -3,39 +3,21 @@
|
|
|
*/
|
|
|
package kr.co.zumo.app.lifeplus.view.screen.contents;
|
|
|
|
|
|
-import android.content.Context;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.Gravity;
|
|
|
-import android.view.LayoutInflater;
|
|
|
-import android.view.View;
|
|
|
-import android.widget.TextView;
|
|
|
-import android.widget.Toast;
|
|
|
-
|
|
|
import kr.co.zumo.app.R;
|
|
|
-import kr.co.zumo.app.lifeplus.application.App;
|
|
|
import kr.co.zumo.app.lifeplus.bean.ContentsDeliveryBean;
|
|
|
import kr.co.zumo.app.lifeplus.helper.DeliveryHelper;
|
|
|
-import kr.co.zumo.app.lifeplus.helper.FacebookHelper;
|
|
|
import kr.co.zumo.app.lifeplus.helper.NavigationBar;
|
|
|
import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
|
|
|
-import kr.co.zumo.app.lifeplus.tool.IShareListener;
|
|
|
import kr.co.zumo.app.lifeplus.tool.Share;
|
|
|
-import kr.co.zumo.app.lifeplus.tool.ShareClipBoard;
|
|
|
-import kr.co.zumo.app.lifeplus.tool.ShareFacebook;
|
|
|
-import kr.co.zumo.app.lifeplus.tool.ShareKakaoTalk;
|
|
|
import kr.co.zumo.app.lifeplus.util.ResourceUtil;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
-import kr.co.zumo.app.lifeplus.view.command.EmailSendingCommand;
|
|
|
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.DialogBase;
|
|
|
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.ICustomDialogListener;
|
|
|
-import kr.co.zumo.app.lifeplus.view.dialog.ShareDialog;
|
|
|
import kr.co.zumo.app.lifeplus.view.dialog.TooltipDialog;
|
|
|
-import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
|
|
|
|
|
|
/**
|
|
|
* ContentsPresenter
|
|
|
@@ -47,64 +29,24 @@ import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
|
|
|
* @history 민효동 [2018. 11. 6.] [최초 작성]
|
|
|
* @since 2018. 11. 6.
|
|
|
*/
|
|
|
-public class ContentsPresenter extends Presenter<ContentsModel, IContentsView> {
|
|
|
+public class ContentsPresenter extends ContentsBasePresenter<ContentsModel, IContentsView> {
|
|
|
|
|
|
- private DialogBase reviewDialog;
|
|
|
- private Share share;
|
|
|
+ protected DialogBase reviewDialog;
|
|
|
+ protected Share share;
|
|
|
|
|
|
public ContentsPresenter(ContentsModel model, IContentsView view) {
|
|
|
super(model, view);
|
|
|
|
|
|
- DeliveryHelper deliveryHelper = getHelper(DeliveryHelper.class);
|
|
|
- ContentsDeliveryBean contentsDeliveryBean = deliveryHelper.getPackaging(ContentsDeliveryBean.class);
|
|
|
-
|
|
|
- if (null != contentsDeliveryBean) {
|
|
|
- Log.w("APP# ContentsPresenter | ContentsPresenter", "|" + contentsDeliveryBean.toPrettyJson());
|
|
|
- this.model.setContentsBean(contentsDeliveryBean.getContentsBean());
|
|
|
-
|
|
|
- deliveryHelper.clearPackaging();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void createViewInternal() {
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void destroyInternal() {
|
|
|
- if (null != reviewDialog) {
|
|
|
- reviewDialog.dispose();
|
|
|
- reviewDialog = null;
|
|
|
- }
|
|
|
-
|
|
|
- if (null != share) {
|
|
|
- share.dispose();
|
|
|
- share = null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void destroyViewInternal() {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void startInternal() {
|
|
|
+ super.startInternal();
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void stopInternal() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void resumeInternal() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void pauseInternal() {
|
|
|
-
|
|
|
+ if (null != model.getContentsBean()) {
|
|
|
+ view.setLiked(model.isLiked());
|
|
|
+ view.setBookmarked(model.isBookmarked());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -119,28 +61,8 @@ public class ContentsPresenter extends Presenter<ContentsModel, IContentsView> {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onResult(Event event) {
|
|
|
- final int subId = event.getInteger();
|
|
|
- final boolean requestedChecked = event.getBool();
|
|
|
- switch (event.getEventId()) {
|
|
|
- case Event.SUCCESS:
|
|
|
- if (subId == Event.CONTENTS_LIKE) {
|
|
|
- view.setLiked(requestedChecked);
|
|
|
- }
|
|
|
- else if (subId == Event.CONTENTS_BOOKMARK) {
|
|
|
- view.setBookmarked(requestedChecked);
|
|
|
- }
|
|
|
- break;
|
|
|
- case Event.ERROR:
|
|
|
- if (subId == Event.CONTENTS_LIKE) {
|
|
|
- }
|
|
|
- else if (subId == Event.CONTENTS_BOOKMARK) {
|
|
|
- }
|
|
|
- showErrorDialog(event.getString());
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ protected void onContentsResultInternal(Event event) {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -182,8 +104,8 @@ public class ContentsPresenter extends Presenter<ContentsModel, IContentsView> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- view.setLiked(model.getContentsBean().isLiked());
|
|
|
- view.setBookmarked(model.getContentsBean().isBookmarked());
|
|
|
+ view.setLiked(model.isLiked());
|
|
|
+ view.setBookmarked(model.isBookmarked());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -224,124 +146,10 @@ public class ContentsPresenter extends Presenter<ContentsModel, IContentsView> {
|
|
|
* @param navigationBar
|
|
|
*/
|
|
|
public void onNavigationClickShare(NavigationBar navigationBar) {
|
|
|
- new DialogBuilder<ShareDialog, ICustomDialogListener>(getFragmentManager(), DialogID.SHARE)
|
|
|
- .listener(new ICustomDialogListener<ShareDialog>() {
|
|
|
- @Override
|
|
|
- public void onDialogResult(ShareDialog dialog, Event event) {
|
|
|
- dialog.dispose();
|
|
|
-
|
|
|
- switch (event.getEventId()) {
|
|
|
- case Event.CLOSE:
|
|
|
- break;
|
|
|
- case Event.KAKAO_TALK:
|
|
|
- sendKakaoLink();
|
|
|
- break;
|
|
|
- case Event.FACE_BOOK:
|
|
|
- sendFaceBook();
|
|
|
- break;
|
|
|
- case Event.CODE_COPY:
|
|
|
- sendClipBoardCopy();
|
|
|
- break;
|
|
|
- case Event.EMAIL_CLICK:
|
|
|
- sendEmail();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onDialogCanceled(ShareDialog dialog) {
|
|
|
- dialog.dispose();
|
|
|
- }
|
|
|
- })
|
|
|
- .attribute(dialog -> {
|
|
|
- dialog.setDialogType(ShareDialog.TYPE_PAGE_CURRENT);
|
|
|
- })
|
|
|
- .show();
|
|
|
- }
|
|
|
-
|
|
|
- private void sendKakaoLink() {
|
|
|
- share = new ShareKakaoTalk(view.getActivity());
|
|
|
- share.shareContents(model.getContentsBean().toJson(), new IShareListener() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String result) {
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(int errorCode, String result) {
|
|
|
- if (ShareKakaoTalk.CLIENT_ERROR_CODE == errorCode) {
|
|
|
- showErrorDialog(ResourceUtil.getString(R.string.please_install_kakaotalk));
|
|
|
- }
|
|
|
- else {
|
|
|
- showErrorDialog(result);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void sendFaceBook() {
|
|
|
- share = new ShareFacebook(view.getActivity(), getHelper(FacebookHelper.class).getCallbackManager());
|
|
|
- share.shareContents(model.getContentsBean().getContentsUrlWithParamForShare(), new IShareListener() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String result) {
|
|
|
- showToast("", ResourceUtil.getString(R.string.share_completed_message), 1);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(int errorCode, String result) {
|
|
|
- showErrorDialog(result);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void sendClipBoardCopy() {
|
|
|
- share = new ShareClipBoard(view.getActivity());
|
|
|
- share.shareContents(model.getContentsBean().getContentsUrlWithParamForShare(), new IShareListener() {
|
|
|
- @Override
|
|
|
- public void onSuccess(String result) {
|
|
|
- showToast("", ResourceUtil.getString(R.string.url_copy_message), 1);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(int errorCode, String result) {
|
|
|
- showErrorDialog(ResourceUtil.getString(R.string.share_error_message));
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void sendEmail() {
|
|
|
- String subject = ResourceUtil.getString(R.string.share_title, model.getContentsBean().getTitle());
|
|
|
- String contents = ResourceUtil.getString(R.string.share_current_page_contents, model.getContentsBean().getTitle(), model.getContentsBean().getContentsUrl());
|
|
|
- onCommand(new EmailSendingCommand("", subject, contents));
|
|
|
- }
|
|
|
-
|
|
|
- private void showToast(String title, String detail, @Nullable int copyToastFlag) {
|
|
|
-
|
|
|
- Context context = App.getInstance().getContext();
|
|
|
- Toast toast = new Toast(context);
|
|
|
- toast.setDuration(Toast.LENGTH_LONG);
|
|
|
- toast.setGravity(Gravity.FILL, 0, 0);
|
|
|
- LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
- View view;
|
|
|
- if (copyToastFlag != 0) {
|
|
|
- view = inflater.inflate(R.layout.setting_toast_url_copy_pop_up, null);
|
|
|
- ((TextView) view.findViewById(R.id.setting_toast_detail)).setText(detail);
|
|
|
- }
|
|
|
- else {
|
|
|
- view = inflater.inflate(R.layout.setting_toast_pop_up, null);
|
|
|
- ((TextView) view.findViewById(R.id.setting_toast_title)).setText(title);
|
|
|
- ((TextView) view.findViewById(R.id.setting_toast_detail)).setText(detail);
|
|
|
- }
|
|
|
-
|
|
|
- toast.setView(view);
|
|
|
- toast.show();
|
|
|
+ showShareDialog();
|
|
|
}
|
|
|
|
|
|
- private void showPopupForGuest() {
|
|
|
+ protected void showPopupForGuest() {
|
|
|
// 비회원 가입 유도
|
|
|
new DialogBuilder<ConfirmDialog, ICustomDialogListener>(getFragmentManager(), DialogID.ALERT)
|
|
|
.listener(new ICustomDialogListener<ConfirmDialog>() {
|
|
|
@@ -365,7 +173,7 @@ public class ContentsPresenter extends Presenter<ContentsModel, IContentsView> {
|
|
|
.show();
|
|
|
}
|
|
|
|
|
|
- private void showTooltipDialog() {
|
|
|
+ protected void showTooltipDialog() {
|
|
|
new DialogBuilder<TooltipDialog, ICustomDialogListener>(getFragmentManager(), DialogID.TOOL_TIP)
|
|
|
.listener(new ICustomDialogListener<TooltipDialog>() {
|
|
|
|