Search in sources :

Example 1 with EventContainer

use of pri.weiqiang.myjapanese.rxbus.event.EventContainer in project MyJapanese by 54wall.

the class MainActivity method initVariable.

@Override
protected void initVariable(@Nullable Bundle savedInstanceState) {
    presenter = new MainActivityPresenterImpl(this);
    if (!registered) {
        busSubscription = RxBus.getDefault().toObserverable(EventContainer.class).subscribe(new Action1<EventContainer>() {

            @Override
            public void call(EventContainer eventContainer) {
                presenter.onBusEventInteraction(eventContainer);
            }
        });
        registered = true;
    }
    initToolbar();
    initRadioButtonView();
    initDrawerLayout();
    initNavigationView();
    initBanner();
// 无效
// mToolbar.setTitle(SharedPreferenceManager.getInstance().getString(Constants.CURRENT_LESSON, Constants.DEFAULT_LESSON));
}
Also used : MainActivityPresenterImpl(pri.weiqiang.myjapanese.mvp.presenter.MainActivityPresenterImpl) Action1(rx.functions.Action1) EventContainer(pri.weiqiang.myjapanese.rxbus.event.EventContainer)

Example 2 with EventContainer

use of pri.weiqiang.myjapanese.rxbus.event.EventContainer 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();
}
Also used : Action1(rx.functions.Action1) EventContainer(pri.weiqiang.myjapanese.rxbus.event.EventContainer) SettingEvent(pri.weiqiang.myjapanese.rxbus.event.SettingEvent)

Example 3 with EventContainer

use of pri.weiqiang.myjapanese.rxbus.event.EventContainer in project MyJapanese by 54wall.

the class GameFragment method initVariable.

@Override
protected void initVariable(@Nullable Bundle savedInstanceState) {
    mPuzzleCardView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            RxBus.getDefault().post(new EventContainer(EventContainer.TYPE_GAME, new GameEvent(GameEvent.TYPE_PUZZLE)));
        }
    });
    mSupperzzleCardView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            RxBus.getDefault().post(new EventContainer(EventContainer.TYPE_GAME, new GameEvent(GameEvent.TYPE_SUPPERZZLE)));
        }
    });
}
Also used : EventContainer(pri.weiqiang.myjapanese.rxbus.event.EventContainer) GameEvent(pri.weiqiang.myjapanese.rxbus.event.GameEvent) CardView(android.support.v7.widget.CardView) View(android.view.View) BindView(butterknife.BindView)

Example 4 with EventContainer

use of pri.weiqiang.myjapanese.rxbus.event.EventContainer 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;
        }
    });
}
Also used : CheckBoxPreference(android.preference.CheckBoxPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) EventContainer(pri.weiqiang.myjapanese.rxbus.event.EventContainer) SettingEvent(pri.weiqiang.myjapanese.rxbus.event.SettingEvent)

Example 5 with EventContainer

use of pri.weiqiang.myjapanese.rxbus.event.EventContainer in project MyJapanese by 54wall.

the class PixivIllustFragment method showImg.

@Override
public void showImg(String url, int id) {
    PhotoViewEvent event = new PhotoViewEvent(url, id);
    RxBus.getDefault().post(new EventContainer(EventContainer.TYPE_PHOTOVIEW, event));
}
Also used : EventContainer(pri.weiqiang.myjapanese.rxbus.event.EventContainer) PhotoViewEvent(pri.weiqiang.myjapanese.rxbus.event.PhotoViewEvent)

Aggregations

EventContainer (pri.weiqiang.myjapanese.rxbus.event.EventContainer)5 SettingEvent (pri.weiqiang.myjapanese.rxbus.event.SettingEvent)2 Action1 (rx.functions.Action1)2 CheckBoxPreference (android.preference.CheckBoxPreference)1 ListPreference (android.preference.ListPreference)1 Preference (android.preference.Preference)1 CardView (android.support.v7.widget.CardView)1 View (android.view.View)1 BindView (butterknife.BindView)1 MainActivityPresenterImpl (pri.weiqiang.myjapanese.mvp.presenter.MainActivityPresenterImpl)1 GameEvent (pri.weiqiang.myjapanese.rxbus.event.GameEvent)1 PhotoViewEvent (pri.weiqiang.myjapanese.rxbus.event.PhotoViewEvent)1