use of com.codeest.geeknews.model.event.NightModeEvent in project GeekNews by codeestX.
the class MainPresenter method registerEvent.
void registerEvent() {
Subscription rxSubscription = RxBus.getDefault().toObservable(NightModeEvent.class).compose(RxUtil.<NightModeEvent>rxSchedulerHelper()).map(new Func1<NightModeEvent, Boolean>() {
@Override
public Boolean call(NightModeEvent nightModeEvent) {
return nightModeEvent.getNightMode();
}
}).subscribe(new CommonSubscriber<Boolean>(mView, "切换模式失败ヽ(≧Д≦)ノ") {
@Override
public void onNext(Boolean aBoolean) {
mView.useNightMode(aBoolean);
}
});
addSubscrebe(rxSubscription);
}
use of com.codeest.geeknews.model.event.NightModeEvent in project GeekNews by codeestX.
the class SettingFragment method onCheckedChanged.
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
switch(compoundButton.getId()) {
case R.id.cb_setting_night:
if (isNull) {
//防止夜间模式MainActivity执行reCreate后重复调用
SharedPreferenceUtil.setNightModeState(b);
NightModeEvent event = new NightModeEvent();
event.setNightMode(b);
RxBus.getDefault().post(event);
}
break;
case R.id.cb_setting_image:
SharedPreferenceUtil.setNoImageState(b);
break;
case R.id.cb_setting_cache:
SharedPreferenceUtil.setAutoCacheState(b);
break;
}
}
Aggregations