use of pri.weiqiang.myjapanese.rxbus.event.SettingEvent in project MyJapanese by 54wall.
the class SettingActivity method initVariable.
@Override
protected void initVariable(@Nullable Bundle savedInstanceState) {
if (!registered) {
subscription = RxBus.getDefault().toObserverable(EventContainer.class).subscribe(new Action1<EventContainer>() {
@Override
public void call(EventContainer eventContainer) {
if (eventContainer.getType() == EventContainer.TYPE_SETTING) {
SettingEvent event = (SettingEvent) eventContainer.getEvent();
showSnackBar(mRootLayout, event.getMsg());
}
}
});
registered = true;
}
initToolbar();
}
use of pri.weiqiang.myjapanese.rxbus.event.SettingEvent in project MyJapanese by 54wall.
the class SettingFragment method initPreference.
private void initPreference() {
mTTSListPreference = (ListPreference) getPreferenceManager().findPreference("setting_tts");
mTTSListPreference.setEntries(R.array.tts_entries);
mTTSListPreference.setEntryValues(R.array.tts_values);
mTTSListPreference.setValue(tts_type);
mTTSListPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
SharedPreferenceManager.getInstance().putString(Constants.TTS_TYPE, (String) newValue);
JpTTSUtils.getInstance().updateTtsType();
RxBus.getDefault().post(new EventContainer(EventContainer.TYPE_SETTING, new SettingEvent(R.string.setting_effect)));
return true;
}
});
mThemesListPreference = (ListPreference) getPreferenceManager().findPreference("setting_theme");
mThemesListPreference.setEntries(R.array.themes_entries);
mThemesListPreference.setEntryValues(R.array.themes_values);
mThemesListPreference.setValue(mode_theme);
mThemesListPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
SharedPreferenceManager.getInstance().putString(Constants.MODE_THEME, (String) newValue);
RxBus.getDefault().post(new EventContainer(EventContainer.TYPE_SETTING, new SettingEvent(R.string.reboot_to_take_effect)));
return true;
}
});
mConnectCheckBoxPreference = (CheckBoxPreference) getPreferenceManager().findPreference("setting_wifi");
mConnectCheckBoxPreference.setChecked(allow_connect);
mConnectCheckBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Log.i(TAG, "onPreferenceChange: " + newValue);
SharedPreferenceManager.getInstance().putBoolean(Constants.ALLOW_CONNECT_WITHOUT_WIFI, (Boolean) newValue);
RxBus.getDefault().post(new EventContainer(EventContainer.TYPE_SETTING, new SettingEvent(R.string.setting_effect)));
return true;
}
});
}
use of pri.weiqiang.myjapanese.rxbus.event.SettingEvent in project MyJapanese by 54wall.
the class MainActivityPresenterImpl method onBusEventInteraction.
@Override
public void onBusEventInteraction(EventContainer eventContainer) {
Log.i(TAG, "onBusEventInteraction: " + eventContainer);
switch(eventContainer.getType()) {
case EventContainer.TYPE_PHOTOVIEW:
PhotoViewEvent photoViewEvent = (PhotoViewEvent) eventContainer.getEvent();
Bundle bundle = new Bundle();
bundle.putString(Constants.IMG_URL, photoViewEvent.getImg_url());
bundle.putInt(Constants.IMG_ID, photoViewEvent.getImg_id());
view.startPhotoViewActivity(bundle);
break;
case EventContainer.TYPE_GAME:
GameEvent gameEvent = (GameEvent) eventContainer.getEvent();
switch(gameEvent.getType()) {
case GameEvent.TYPE_PUZZLE:
view.startPuzzleActivity();
break;
case GameEvent.TYPE_SUPPERZZLE:
view.startSupperzzleActivity();
break;
default:
break;
}
break;
case EventContainer.TYPE_SETTING:
SettingEvent event = (SettingEvent) eventContainer.getEvent();
view.showSnackBar(event.getMsg());
break;
default:
break;
}
}
Aggregations