|
|
@@ -12,9 +12,6 @@ import android.util.Log;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
-import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
-import io.reactivex.disposables.CompositeDisposable;
|
|
|
-import io.reactivex.schedulers.Schedulers;
|
|
|
import kr.co.zumo.app.R;
|
|
|
import kr.co.zumo.app.lifeplus.activity.ActivityBase;
|
|
|
import kr.co.zumo.app.lifeplus.activity.AppInitializer;
|
|
|
@@ -22,27 +19,16 @@ import kr.co.zumo.app.lifeplus.activity.DynamicLinkLauncher;
|
|
|
import kr.co.zumo.app.lifeplus.activity.MainActivity;
|
|
|
import kr.co.zumo.app.lifeplus.activity.ScreenStarter;
|
|
|
import kr.co.zumo.app.lifeplus.application.App;
|
|
|
-import kr.co.zumo.app.lifeplus.bean.api.LifeplusAPIBean;
|
|
|
-import kr.co.zumo.app.lifeplus.helper.AppShieldHelper;
|
|
|
-import kr.co.zumo.app.lifeplus.helper.AppVersionHelper;
|
|
|
import kr.co.zumo.app.lifeplus.helper.FirebaseMessagingHelper;
|
|
|
import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
import kr.co.zumo.app.lifeplus.model.SuperModelInit;
|
|
|
-import kr.co.zumo.app.lifeplus.model.module.APIError;
|
|
|
import kr.co.zumo.app.lifeplus.model.module.APIModuleHelper;
|
|
|
-import kr.co.zumo.app.lifeplus.model.module.APIModuleListener;
|
|
|
-import kr.co.zumo.app.lifeplus.network.NetworkWatcher;
|
|
|
import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
|
|
|
-import kr.co.zumo.app.lifeplus.util.AppUtil;
|
|
|
import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
-import kr.co.zumo.app.lifeplus.view.command.AppUpdateCommand;
|
|
|
-import kr.co.zumo.app.lifeplus.view.command.ExitCommand;
|
|
|
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.DialogProvider;
|
|
|
import kr.co.zumo.app.lifeplus.view.dialog.ICustomConfirmListener;
|
|
|
-import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.setting.MemberInfoModelHelper;
|
|
|
import kr.co.zumo.app.lifeplus.zumo.bean.api.MemberInfoBean;
|
|
|
|
|
|
@@ -56,13 +42,10 @@ import kr.co.zumo.app.lifeplus.zumo.bean.api.MemberInfoBean;
|
|
|
* @history 민효동 [2019-04-02] [최초 작성]
|
|
|
* @since 2019-04-02
|
|
|
*/
|
|
|
-public class SplashPresenter extends Presenter<SplashModel, ISplashView> {
|
|
|
+public class SplashPresenter extends ScreenStarterPresenter<SplashModel, ISplashView> {
|
|
|
|
|
|
private final static int REQUEST_CODE = 9909;
|
|
|
|
|
|
- private CompositeDisposable disposable = new CompositeDisposable();
|
|
|
- private ScreenStarter starter;
|
|
|
-
|
|
|
private boolean isRequestingLocationService = false;
|
|
|
|
|
|
public SplashPresenter(SplashModel model, ISplashView view) {
|
|
|
@@ -75,17 +58,7 @@ public class SplashPresenter extends Presenter<SplashModel, ISplashView> {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected void destroyInternal() {
|
|
|
-
|
|
|
- if (null != disposable) {
|
|
|
- disposable.dispose();
|
|
|
- disposable = null;
|
|
|
- }
|
|
|
- if (null != starter) {
|
|
|
- starter.dispose();
|
|
|
- starter = null;
|
|
|
- }
|
|
|
- view = null;
|
|
|
+ protected void destroyInternal2() {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -113,10 +86,7 @@ public class SplashPresenter extends Presenter<SplashModel, ISplashView> {
|
|
|
|
|
|
launchPushPermission(() -> {
|
|
|
launchDeviceLocationPermission(() -> {
|
|
|
- launchLocationPermission(() -> {
|
|
|
- // 권한 처리 종료
|
|
|
- onPermissionCompleted();
|
|
|
- });
|
|
|
+ launchLocationPermission(/* 권한 처리 종료 */this::onPermissionCompleted);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
@@ -132,10 +102,7 @@ public class SplashPresenter extends Presenter<SplashModel, ISplashView> {
|
|
|
if (isRequestingLocationService) {
|
|
|
isRequestingLocationService = false;
|
|
|
|
|
|
- launchLocationPermission(() -> {
|
|
|
- // 권한 처리 종료
|
|
|
- onPermissionCompleted();
|
|
|
- });
|
|
|
+ launchLocationPermission(/* 권한 처리 종료 */this::onPermissionCompleted);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -258,6 +225,7 @@ public class SplashPresenter extends Presenter<SplashModel, ISplashView> {
|
|
|
}
|
|
|
|
|
|
private void launchInternal(Runnable runnableConfirm, Runnable runnableNext, int titleId, int contentsId, int negativeId, int positiveId) {
|
|
|
+ // todo dialogProvider 로 이동
|
|
|
new DialogBuilder<ConfirmDialog, ICustomConfirmListener>(view.getActivity().getSupportFragmentManager(), DialogID.CONFIRM)
|
|
|
.listener(new ICustomConfirmListener<ConfirmDialog>() {
|
|
|
@Override
|
|
|
@@ -288,33 +256,14 @@ public class SplashPresenter extends Presenter<SplashModel, ISplashView> {
|
|
|
.show();
|
|
|
}
|
|
|
|
|
|
- public void onRequestPermissionsResult(String[] permissions, int[] grantResults) {
|
|
|
- Log.i("APP# SplashPresenter | onRequestPermissionsResult", "|" + " grantResults: " + Arrays.toString(grantResults));
|
|
|
- // If request is cancelled, the result arrays are empty.
|
|
|
- if (grantResults.length > 0) {
|
|
|
- // permission was granted
|
|
|
- boolean granted = true;
|
|
|
- for (int grantResult : grantResults) {
|
|
|
- if (grantResult != PackageManager.PERMISSION_GRANTED) {
|
|
|
- granted = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (granted) {
|
|
|
- // 모두 허용
|
|
|
- model.setLocationServiceEnabled(true);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 권한 처리 종료
|
|
|
- onPermissionCompleted();
|
|
|
- }
|
|
|
-
|
|
|
private void onPermissionCompleted() {
|
|
|
setupInternal();
|
|
|
}
|
|
|
|
|
|
+ private void doOnLink() {
|
|
|
+ DynamicLinkLauncher.launch(view.getActivity());
|
|
|
+ }
|
|
|
+
|
|
|
private void setupInternal() {
|
|
|
|
|
|
Context context = App.getInstance().getContext();
|
|
|
@@ -332,55 +281,25 @@ public class SplashPresenter extends Presenter<SplashModel, ISplashView> {
|
|
|
|
|
|
SuperModelInit.instant(context);
|
|
|
|
|
|
- starter = new ScreenStarter(view.getActivity());
|
|
|
-
|
|
|
- // 네트워크 연결 체크
|
|
|
- disposable.add(
|
|
|
- new NetworkWatcher().check(context)
|
|
|
- .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(isConnected -> {
|
|
|
- disposable.dispose();
|
|
|
-
|
|
|
- if (isConnected) {
|
|
|
- AppShieldHelper.getInstance().checkApp(context);
|
|
|
- AppVersionHelper.getInstance().fetch(view.getActivity(), flag -> {
|
|
|
- switch (flag) {
|
|
|
- case AppVersionHelper.IAppVersionListener.FLAG_FORCE:
|
|
|
- // 강제 업데이트
|
|
|
- showPopupAppUpdate();
|
|
|
- break;
|
|
|
- case AppVersionHelper.IAppVersionListener.FLAG_LATEST:
|
|
|
- // 선택 업데이트
|
|
|
- showPopupAppUpdateLatest();
|
|
|
- break;
|
|
|
- case AppVersionHelper.IAppVersionListener.FLAG_UNABLE:
|
|
|
- /* falls through */
|
|
|
- default:
|
|
|
- launchStarter(true);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- );
|
|
|
- }
|
|
|
- else {
|
|
|
- launchStarter(isConnected);
|
|
|
- }
|
|
|
- }, Throwable::printStackTrace)
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
+ model.checkNetwork(context, isConnected -> {
|
|
|
+ if (isConnected) {
|
|
|
+ checkAppStatus();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ launchStarter(isConnected);
|
|
|
+ }
|
|
|
+ }, Throwable::printStackTrace);
|
|
|
|
|
|
- private void doOnLink() {
|
|
|
- DynamicLinkLauncher.launch(view.getActivity());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private void launchStarter(boolean isConnected) {
|
|
|
- Context context = App.getInstance().getContext();
|
|
|
- starter.launch(isConnected, (context1, fragmentFlag, memberStatus) -> {
|
|
|
+ @Override
|
|
|
+ protected ScreenStarter.IListener onScreenStarterResult() {
|
|
|
+ return (context, fragmentFlag, memberStatus) -> {
|
|
|
/**
|
|
|
* App init
|
|
|
*/
|
|
|
- AppInitializer.init(context);
|
|
|
+ AppInitializer.init(App.getInstance().getContext());
|
|
|
|
|
|
// topic 가입
|
|
|
FirebaseMessagingHelper.getInstance().subscribeToTopic();
|
|
|
@@ -393,62 +312,12 @@ public class SplashPresenter extends Presenter<SplashModel, ISplashView> {
|
|
|
linkActivity(fragmentFlag);
|
|
|
}
|
|
|
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void showRestPopup() {
|
|
|
- DialogProvider.of(view.getActivity().getSupportFragmentManager()).showRestDialog(() -> {
|
|
|
- activateMember();
|
|
|
- }, () -> {
|
|
|
- // 앱 종료
|
|
|
- exit();
|
|
|
- });
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
- private void activateMember() {
|
|
|
- // 휴면 해제
|
|
|
- model.activateMember(new APIModuleListener<LifeplusAPIBean>() {
|
|
|
- @Override
|
|
|
- public void onApiSuccess(LifeplusAPIBean resultBean) {
|
|
|
- linkActivity(ScreenStarter.SCREEN_MAIN);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onApiError(String errorMessage, APIError error) {
|
|
|
- DialogProvider.of(view.getActivity().getSupportFragmentManager()).showErrorDialog(errorMessage, () -> {
|
|
|
- // 앱 종료
|
|
|
- exit();
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void showPopupAppUpdate() {
|
|
|
- DialogProvider.of(view.getActivity().getSupportFragmentManager()).showPopupAppUpdate(() -> {
|
|
|
- gotoPlayStore();
|
|
|
- }, () -> {
|
|
|
- // 앱 종료
|
|
|
- exit();
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void showPopupAppUpdateLatest() {
|
|
|
- DialogProvider.of(view.getActivity().getSupportFragmentManager()).showPopupAppUpdateLatest(() -> {
|
|
|
- gotoPlayStore();
|
|
|
- }, () -> {
|
|
|
- // 다음 진행
|
|
|
- launchStarter(true);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void gotoPlayStore() {
|
|
|
- // 플레이 스토어 이동
|
|
|
- onCommand(new AppUpdateCommand(AppUtil.getPackageName()));
|
|
|
- }
|
|
|
-
|
|
|
- protected void exit() {
|
|
|
- onCommand(new ExitCommand());
|
|
|
+ @Override
|
|
|
+ protected void onActivateSuccess() {
|
|
|
+ linkActivity(ScreenStarter.SCREEN_MAIN);
|
|
|
}
|
|
|
|
|
|
}
|