Search in sources :

Example 1 with GameEvent

use of pri.weiqiang.myjapanese.rxbus.event.GameEvent 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 2 with GameEvent

use of pri.weiqiang.myjapanese.rxbus.event.GameEvent 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;
    }
}
Also used : Bundle(android.os.Bundle) SettingEvent(pri.weiqiang.myjapanese.rxbus.event.SettingEvent) PhotoViewEvent(pri.weiqiang.myjapanese.rxbus.event.PhotoViewEvent) GameEvent(pri.weiqiang.myjapanese.rxbus.event.GameEvent)

Aggregations

GameEvent (pri.weiqiang.myjapanese.rxbus.event.GameEvent)2 Bundle (android.os.Bundle)1 CardView (android.support.v7.widget.CardView)1 View (android.view.View)1 BindView (butterknife.BindView)1 EventContainer (pri.weiqiang.myjapanese.rxbus.event.EventContainer)1 PhotoViewEvent (pri.weiqiang.myjapanese.rxbus.event.PhotoViewEvent)1 SettingEvent (pri.weiqiang.myjapanese.rxbus.event.SettingEvent)1