|
|
@@ -1,134 +0,0 @@
|
|
|
-/*
|
|
|
- * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
|
|
|
- */
|
|
|
-package kr.co.zumo.app.lifeplus.view.screen.error;
|
|
|
-
|
|
|
-import android.util.Log;
|
|
|
-
|
|
|
-import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
-import io.reactivex.disposables.Disposable;
|
|
|
-import io.reactivex.schedulers.Schedulers;
|
|
|
-import kr.co.zumo.app.lifeplus.application.App;
|
|
|
-import kr.co.zumo.app.lifeplus.model.BlankModel;
|
|
|
-import kr.co.zumo.app.lifeplus.network.NetworkWatcher;
|
|
|
-import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
|
|
|
-import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
-import kr.co.zumo.app.lifeplus.view.command.ExitCommand;
|
|
|
-import kr.co.zumo.app.lifeplus.view.presenter.Presenter;
|
|
|
-
|
|
|
-/**
|
|
|
- * NetworkErrorPresenter
|
|
|
- * <pre>
|
|
|
- * </pre>
|
|
|
- *
|
|
|
- * @author 민효동
|
|
|
- * @version 1.0
|
|
|
- * @history 민효동 [2018. 9. 21.] [최초 작성]
|
|
|
- * @since 2018. 9. 21.
|
|
|
- */
|
|
|
-public class NetworkErrorPresenter extends Presenter<BlankModel, INetworkErrorView> {
|
|
|
-
|
|
|
- protected Disposable disposable;
|
|
|
-
|
|
|
- public NetworkErrorPresenter(BlankModel model, INetworkErrorView view) {
|
|
|
- super(model, view);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void startInternal() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void stopInternal() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void resumeInternal() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void pauseInternal() {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void destroyViewInternal() {
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void createViewInternal() {
|
|
|
- }
|
|
|
- @Override
|
|
|
- protected void destroyInternal() {
|
|
|
- if (null != disposable) {
|
|
|
- disposable.dispose();
|
|
|
- disposable = null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onBackPressed() {
|
|
|
- onCommand(new ExitCommand());
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onEventInternal(Event event) {
|
|
|
- switch (event.getEventId()) {
|
|
|
- case Event.RETRY:
|
|
|
- retry();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void retry() {
|
|
|
- /**
|
|
|
- * 네트워크 연결 다시 시도
|
|
|
- * - 연결됐다면 메인으로 이동
|
|
|
- */
|
|
|
- disposable = new NetworkWatcher().check(App.getInstance().getContext())
|
|
|
- .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(isConnected -> {
|
|
|
- Log.i("APP# NetworkErrorPresenter | checkNetworkConnection", "| isConnected: " + isConnected);
|
|
|
- if (isConnected) {
|
|
|
- next();
|
|
|
- }
|
|
|
- else {
|
|
|
- // 그냥 그대로 있음;
|
|
|
- }
|
|
|
- }, Throwable::printStackTrace);
|
|
|
- }
|
|
|
-
|
|
|
- protected void next() {
|
|
|
-
|
|
|
- // 사용 중 에러로 진입 할 경우
|
|
|
- back(ScreenID.MAIN);
|
|
|
- }
|
|
|
-
|
|
|
- /***********************************
|
|
|
- * listener
|
|
|
- ***********************************/
|
|
|
- @Override
|
|
|
- public void onChangedConnection(boolean isConnected, int type) {
|
|
|
- Log.i("APP# NetworkErrorPresenter | onChangedConnection", "| " + this.getClass().getSimpleName() + ", isConnected:" + isConnected);
|
|
|
-
|
|
|
- if (true == isConnected) {
|
|
|
- next();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onResult(Event event) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onScreenReady() {
|
|
|
-
|
|
|
- }
|
|
|
-}
|