Skip to content

Commit

Permalink
yoyiyi
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyiyi committed Sep 14, 2017
1 parent ee127c1 commit dbced10
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
26 changes: 23 additions & 3 deletions app/src/main/java/com/yoyiyi/soleil/base/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
import com.yoyiyi.soleil.di.component.ActivityComponent;
import com.yoyiyi.soleil.di.component.DaggerActivityComponent;
import com.yoyiyi.soleil.di.module.ActivityModule;
import com.yoyiyi.soleil.event.Event;
import com.yoyiyi.soleil.rx.RxBus;
import com.yoyiyi.soleil.utils.AppUtils;
import com.yoyiyi.soleil.widget.statusbar.StatusBarUtil;

import javax.inject.Inject;

import butterknife.ButterKnife;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;


/**
Expand All @@ -36,6 +40,7 @@ public abstract class BaseActivity<T extends BaseContract.BasePresenter> extends
// protected DrawerLayout mDrawerLayout;
protected boolean mBack = true;
private ConstraintLayout mError;
private Disposable mDisposable;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -60,6 +65,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
initWidget();
initDatas();
initExit();
}


Expand All @@ -74,6 +80,17 @@ protected ActivityComponent getActivityComponent() {
.build();
}


private void initExit() {
mDisposable = RxBus.INSTANCE.toDefaultFlowable(Event.ExitEvent.class, exitEvent -> {
if (exitEvent.exit == -1) {
finish();
}
});


}

/**
* 注入依赖
*/
Expand Down Expand Up @@ -104,9 +121,9 @@ protected void initStatusBar() {

@Override
protected void onSaveInstanceState(Bundle outState) {
//如果用以下这种做法则不保存状态,再次进来的话会显示默认tab
//总是执行这句代码来调用父类去保存视图层的状态
//super.onSaveInstanceState(outState);
//如果用以下这种做法则不保存状态,再次进来的话会显示默认tab
//总是执行这句代码来调用父类去保存视图层的状态
//super.onSaveInstanceState(outState);
}

/**
Expand Down Expand Up @@ -141,6 +158,9 @@ protected void onDestroy() {
if (mPresenter != null) mPresenter.detachView();
BiliSoleilApplication.getInstance().removeActivity(this);
super.onDestroy();
if (!mDisposable.isDisposed()) {
mDisposable.dispose();
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/yoyiyi/soleil/event/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public static class RegionEntrancePositionEvent {
public int position;
}

public static class ExitEvent {
public int exit;
}

public static class AllStationPositionEvent {
public int position;
}
Expand Down

0 comments on commit dbced10

Please sign in to comment.