Java 类org.greenrobot.eventbus.ThreadMode 实例源码

项目:PandwarfDefenderProject    文件:Main2Activity.java   
/**
 * Used by EventBus
 * Called when a Publisher send a action to be executed.
 * @param actionEvent
 */
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(final ActionEvent actionEvent) {
    switch (actionEvent.getActionRequested()) {
        case START_FAST_PROTECTION_ANALYZER:
        case STOP_FAST_PROTECTION_ANALYZER:
        case START_SEARCH_THRESHOLD:
        case STOP_SEARCH_THRESHOLD:
        case START_PROTECTION:
        case STOP_PROTECTION: {
            TaskPollManager.getInstance().put(actionEvent);
            break;
        }
        case START_JAMMING: {
            toastShow("Attack detected");

            Logger.d(TAG, "Attack detected");
            TaskPollManager.getInstance().put(actionEvent);
            break;
        }
    }
}
项目:Obd2-Tracker    文件:MainPresenter.java   
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onObdJob(ObdJobEvent obdJobEvent) {

    String name = obdJobEvent.getObdCommandJob().getObdCommand().getName();
    String result = obdJobEvent.getObdCommandJob().getObdCommand().getResult();

    if (result == null) {

    } else if (result.equals("NODATA")) {
        log.debug(name + ": " + obdJobEvent.getObdCommandJob().getObdCommand().getResult());
    } else {
        String formattedResult = obdJobEvent.getObdCommandJob().getObdCommand().getFormattedResult();
        log.info(name + ": " + formattedResult);
        obdData.put(name, formattedResult + "  :::  " + new Date().getTime());
        getView().showObdData(obdData);
    }
}
项目:Remote    文件:Home.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(GetViewStackEvent event) {
    if (event.getStatus() != 1) return;
    try {
        JSONObject result = new JSONObject(event.getResponse() + "");
        int length = result.getJSONObject("result").getJSONArray("viewstack").length();
        if (result.getJSONObject("result").getJSONArray("viewstack").getString(length - 1).equals("movie-detail")) {
            startActivity(new Intent(Home.this, MovieDetailsActivity.class));
        } else if (result.getJSONObject("result").getJSONArray("viewstack").getString(length - 1).equals("shows-container-contain")) {
            startActivity(new Intent(Home.this, ShowDetails.class));
        } else if (result.getJSONObject("result").getJSONArray("viewstack").getString(length - 1).equals("about")) {

        } else if (result.getJSONObject("result").getJSONArray("viewstack").getString(length - 1).equals("settings-container-contain")) {

        }


    } catch (JSONException e) {
        e.printStackTrace();
    }
}
项目:BookReader-master    文件:ReadActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void downloadMessage(final DownloadMessage msg) {
    if (isVisible(mLlBookReadBottom)) { // 如果工具栏显示,则进度条也显示
        if (bookId.equals(msg.bookId)) {
            visible(mTvDownloadProgress);
            mTvDownloadProgress.setText(msg.message);
            if (msg.isComplete) {
                mTvDownloadProgress.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        gone(mTvDownloadProgress);
                    }
                }, 2500);
            }
        }
    }
}
项目:PeSanKita-android    文件:WebRtcCallActivity.java   
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(final WebRtcViewModel event) {
  Log.w(TAG, "Got message from service: " + event);

  switch (event.getState()) {
    case CALL_CONNECTED:          handleCallConnected(event);            break;
    case NETWORK_FAILURE:         handleServerFailure(event);            break;
    case CALL_RINGING:            handleCallRinging(event);              break;
    case CALL_DISCONNECTED:       handleTerminate(event.getRecipient()); break;
    case NO_SUCH_USER:            handleNoSuchUser(event);               break;
    case RECIPIENT_UNAVAILABLE:   handleRecipientUnavailable(event);     break;
    case CALL_INCOMING:           handleIncomingCall(event);             break;
    case CALL_OUTGOING:           handleOutgoingCall(event);             break;
    case CALL_BUSY:               handleCallBusy(event);                 break;
    case UNTRUSTED_IDENTITY:      handleUntrustedIdentity(event);        break;
  }

  callScreen.setLocalVideoEnabled(event.isLocalVideoEnabled());
  callScreen.setRemoteVideoEnabled(event.isRemoteVideoEnabled());
  callScreen.updateAudioState(event.isBluetoothAvailable(), event.isMicrophoneEnabled());
  callScreen.setControlsEnabled(event.getState() != WebRtcViewModel.State.CALL_INCOMING);
}
项目:AssistantBySDK    文件:BaseEditDialog.java   
/**
 * new end 刷新录音话筒图标状态
 **/
@Subscribe(threadMode = ThreadMode.MAIN)
public void updateVoiceState(RecordUpdateEvent e) {
    switch (e.getState()) {
        case RecordUpdateEvent.RECORD_IDLE:
        case RecordUpdateEvent.RECORD_IDLE_AFTER_RECOGNIZED:
            voiceButton.setRecordIdleState();
            break;
        case RecordUpdateEvent.RECORDING:
            voiceButton.setRecordStartState();
            break;
        case RecordUpdateEvent.RECOGNIZING:
            voiceButton.setRecognizeCompletedState();
            break;
    }
    //        voiceButton.setHeadSetMode(((MainActivity) context).isHeadset);
}
项目:streaminglib    文件:RtpServerStream.java   
@Subscribe(threadMode = ThreadMode.ASYNC)
public void handleEvent(RtspClientStreamEvent.MediaDataReceived event) {
    Log.d(TAG, "handleEvent: RtspClientStreamEvent.MediaDataReceived");

    try {
        switch (rtpProtocol) {
            case UDP:
                sendRtp(event.data);
                break;
            case TCP:
                Rtsp r = new RtspInterleavedData(interleavedRtpChannels.first, event.data);
                rtspSession.sendRtsp(r);
                break;
        }
    } catch (IOException e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}
项目:AssistantBySDK    文件:NaviSetLineActivity.java   
/**
 * 话筒状态更新处理
 **/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onRecordUpdateEvent(RecordUpdateEvent e) {
    switch (e.getState()) {
        case RecordUpdateEvent.RECORD_IDLE:
        case RecordUpdateEvent.RECORD_IDLE_AFTER_RECOGNIZED:
            mAnslVoiceBt.setRecordIdleState();
            break;
        case RecordUpdateEvent.RECORDING:
            mAnslVoiceBt.setRecordStartState();
            break;
        case RecordUpdateEvent.RECOGNIZING:
            mAnslVoiceBt.setRecognizeCompletedState();
            break;
    }
}
项目:AssistantBySDK    文件:NaviSetLineActivity.java   
/**
 * 导航相关指令处理
 **/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onNetWorkEvent(NetWorkEvent event) {
    if(event.getType()==0){
        closeLoading();
       //  showSnackBar("网络状态不佳,请检查网络设置");
       // Toast.makeText(NaviSetLineActivity.this,"网络状态不佳,请检查网络设置",Toast.LENGTH_LONG).show();
        final CommonDialog commonDialog =  new CommonDialog(this,"网络错误","网络状态不佳,请检查网络设置","确定");
        commonDialog.setOnConfirmListener(new CommonDialog.OnConfirmListener() {
            @Override
            public void onConfirm() {
                commonDialog.cancel();
            }
        }).show();
        return;

    }

}
项目:DOUSalaries    文件:MainActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public void onEvent(SyncEvent event) {
    switch (event.getCode()) {
        case SyncEvent.START_SYNC:
            showLoading();
            break;
        case SyncEvent.END_SYNC:
            hideLoading();
            EventBus.getDefault().post(new SyncEvent(SyncEvent.UPDATE_SYNC, ""));
            EventBus.getDefault().removeStickyEvent(event);
            break;
    }
    if(!event.getStatus().isEmpty()){
        Toast.makeText(this, event.getStatus(), Toast.LENGTH_SHORT).show();
    }
}
项目:ANNO1404-Warenrechner-App    文件:ChainsAdapter.java   
@Subscribe(threadMode = ThreadMode.MAIN)
@SuppressWarnings("unused")
public void onMessageEvent(ChainsResultEvent event) {
    if (event.isGame(game)) {
        this.chainsData = event.getResult();
        notifyDataSetChanged();
    }
}
项目:MultiplicationBasile    文件:RecordsActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventScoreLoaded(List<Score> scores) {
    dataSet.clear();
    for (Score score : scores) {
        Log.e(TAG," ascore has been found for table "+score.getMultiplicationTable());
        dataSet.add(score);
    }
    arrayAdapter.notifyDataSetChanged();
}
项目:anitrend-app    文件:AnimeOverviewFragment.java   
/**
 * Responds to published events
 *
 * @param param
 */
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventPublished(Series param) {
    if(!isRemoving() && model == null) {
        model = param;
        updateUI();
    }
}
项目:Remote    文件:Home.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(GetVolumeEvent event) {
    if (event.getStatus() != 1) return;
    try {
        JSONObject result = new JSONObject(event.getResponse() + "");
        currentVolume = result.getJSONObject("result").getDouble("volume");
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
项目:tumbviewer    文件:MainActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public void refreshData(EventRefresh refreshEvent) {
    EventBus.getDefault().removeStickyEvent(refreshEvent);
    videoFragment.refreshData();
    photoFragment.refreshData();
    searchFragment.refreshData();
    userFragment.refreshData();
    viewPager.setCurrentItem(0);
}
项目:TextReader    文件:BookDetailDiscussionFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void initCategoryList(SelectionEvent event) {
    if (getUserVisibleHint()) {
        mRecyclerView.setRefreshing(true);
        sort = event.sort;
        onRefresh();
    }
}
项目:RetrofitAppArchitecture    文件:RequestControllableActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
@Override
public void onPreNetRequest(EventPreNetRequest event) {
    if (mFreedomRequestHandler.isFreedomRequest(event.mRequest)) {
        mFreedomRequestHandler.onPreNetRequest(event);
        return;
    }

    if (!isManagedRequest(event.mRequest)) return;

    mController.onPreNetRequest(event);
    handlePreNetRequest(event.mRequest);
}
项目:RetrofitAppArchitecture    文件:RequestControllableActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
@Override
public void onReceiveResponse(EventResponse event) {
    if (mFreedomRequestHandler.isFreedomRequest(event.mRequest)) {
        mFreedomRequestHandler.onReceiveResponse(event);
        return;
    }

    if (!isManagedRequest(event.mRequest)) return;

    mController.onReceiveResponse(event);
    handleReceivedResponse(event);
}
项目:Remote    文件:ShowDetails.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(GetVolumeEvent event) {
    if (event.getStatus() != 1) return;
    try {
        JSONObject result = new JSONObject(event.getResponse() + "");
        currentVolume = result.getJSONObject("result").getDouble("volume");
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
项目:diycode    文件:UserActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onUser(GetUserEvent event) {
    if (event.isOk()) {
        UserDetail user = event.getBean();
        mDiycode.getUserCreateTopicList(user.getLogin(), null, 0, user.getTopics_count());
        Logger.e("返回 user 成功");
    } else {
    }
}
项目:Remote    文件:MovieDetailsActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(GetViewStackEvent event) {
    if (event.getStatus() != 1) return;
    try {
        JSONObject result = new JSONObject(event.getResponse() + "");
        int length = result.getJSONObject("result").getJSONArray("viewstack").length();
        if (!result.getJSONObject("result").getJSONArray("viewstack").getString(length - 1).equals("movie-detail")) {
            finish();
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
项目:exciting-app    文件:ShareWechat.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(NetUtilsEvent event) {
    if (shareListener == null)
        return;

    if (event.getMediaType() != ShareConstant.SHARE_MEDIA.WECHAT)
        return;

    switch (event.getResult()) {
        case MyNetUtils.NETWORK_RESULT_FAIL:
            ShareException exception = new ShareException("NETWORK_RESULT_FAIL");
            shareListener.onException(ShareConstant.GET_INFO, ShareConstant.SHARE_MEDIA.WECHAT, exception);
            break;

        case MyNetUtils.NETWORK_RESULT_SUCCESS:
            UserInfoEvent userInfoEvent = new UserInfoEvent();
            if (event.getUseradata() != null)
                userInfoEvent.setUseradata(event.getUseradata());
            userInfoEvent.setPlatform(ShareConstant.SHARE_MEDIA.WECHAT);
            userInfoEvent.setJsonStr(event.getMsg());
            shareListener.onComplete(ShareConstant.GET_INFO, ShareConstant.SHARE_MEDIA.WECHAT, userInfoEvent);
            break;

        case MyNetUtils.NETWORK_RESULT_JSON_EXCEPTION:
            ShareException jsonException = new ShareException("NETWORK_RESULT_JSON_EXCEPTION");
            shareListener.onException(ShareConstant.GET_INFO, ShareConstant.SHARE_MEDIA.WECHAT, jsonException);
            break;

        case MyNetUtils.NETWORK_RESULT_RETURN_NULL:
            ShareException nullException = new ShareException("NETWORK_RESULT_RETURN_NULL");
            shareListener.onException(ShareConstant.GET_INFO, ShareConstant.SHARE_MEDIA.WECHAT, nullException);
            break;

        default:
            break;
    }

}
项目:GitHub    文件:RecommendFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void downloadMessage(final DownloadMessage msg) {
    mRecyclerView.setTipViewText(msg.message);
    if (msg.isComplete) {
        mRecyclerView.hideTipView(2200);
    }
}
项目:Cable-Android    文件:TransferControlView.java   
@Subscribe(sticky = true, threadMode = ThreadMode.ASYNC)
public void onEventAsync(final PartProgressEvent event) {
  if (this.slide != null && event.attachment.equals(this.slide.asAttachment())) {
    Util.runOnMain(new Runnable() {
      @Override
      public void run() {
        progressWheel.setInstantProgress(((float)event.progress) / event.total);
      }
    });
  }
}
项目:GitHub    文件:GirlBookDiscussionFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void initCategoryList(SelectionEvent event) {
    mRecyclerView.setRefreshing(true);
    sort = event.sort;
    distillate = event.distillate;
    onRefresh();
}
项目:grblcontroller    文件:ProbingTabFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onGrblProbeEvent(GrblProbeEvent event){

    if(probeType == null || probeStartPosition == null) return;
    if(!event.getIsProbeSuccess()){
        EventBus.getDefault().post(new UiToastEvent("Probe failed, please try again"));
        fragmentInteractionListener.onGcodeCommandReceived("G53G0Z" + probeStartPosition.toString());
        probeType = null;
        return;
    }

    if(probeType == PROBE_TYPE_NORMAL){
        if(autoZeroAfterProbe.isChecked()){
            Double probePlateThickness = Double.parseDouble(probingPlateThickness.getText().toString());
            fragmentInteractionListener.onGcodeCommandReceived("G53G0Z" + event.getProbeCordZ().toString());
            fragmentInteractionListener.onGcodeCommandReceived("G10L20P0Z" + probePlateThickness);
            autoZeroAfterProbe.setChecked(false);
            autoZeroInLastProbe = true;
            EventBus.getDefault().post(new UiToastEvent("Probe success with auto adjust"));
        }else{
            autoZeroInLastProbe = false;
            EventBus.getDefault().post(new UiToastEvent("Probe success"));
        }
    }

    if(probeType == PROBE_TYPE_TOOL_OFFSET){
        Double lastProbeCordZ = Math.abs(machineStatus.getLastProbePosition().getCordZ());
        Double currentProbeCordZ = Math.abs(event.getProbeCordZ());

        Double toolOffset =  lastProbeCordZ - currentProbeCordZ;
        fragmentInteractionListener.onGcodeCommandReceived("G43.1Z" + toolOffset.toString());
        fragmentInteractionListener.onGcodeCommandReceived(GrblUtils.GRBL_VIEW_GCODE_PARAMETERS_COMMAND);
        EventBus.getDefault().post(new UiToastEvent("Probe success. Tool length offset applied"));
    }

    fragmentInteractionListener.onGcodeCommandReceived("G53G0Z" + probeStartPosition.toString());
    probeStartPosition = null; probeType = null;
    machineStatus.setLastProbePosition(event.getProbePosition());
}
项目:exciting-app    文件:TheHostVoiceMenuFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EventShare share) {
    if (share.isShare())
        ProgressBarHelper.getInstance(true).show(getActivity(), "正在进行分享, 请稍后");
    else
        ProgressBarHelper.getInstance(true).dismiss();
}
项目:anitrend-app    文件:DefaultResultFragment.java   
/**
 * Search page fragments
 *
 * @param query
 */
@Subscribe(threadMode = ThreadMode.MAIN)
@Override
public void update(String query) {
    if(mAdapter != null) {
        mAdapter.getFilter().filter(query);
    }
}
项目:BizareChat    文件:ChatRoomFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
@Keep
public void onPrivateMessageEvent(PrivateMessageEvent event) {
    if (presenter.getType() == DialogsType.PRIVATE_CHAT) {
        presenter.processPrivateMessage(event.getMessage());
    }
}
项目:exciting-app    文件:MyImageViewDrawableOverlay.java   
@Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(EventIsStickerPage page) {
//        unRegisterEvent();
        if (this.page == page.getPage())
            return;
        if (mOverlayView != null) {
            mOverlayView.setSelected(false);
        }

        postInvalidate();

        mOverlayView = null;
    }
项目:pc-android-controller-android    文件:ScreenRecodeService.java   
@Subscribe(threadMode = ThreadMode.MAIN)
    public void onEncodeStop (EventBusConstants.ScreenRecodeStop stop) {
//        if (encoder != null) {
//            encoder.stop();
//        }
        isNeedSendData = false;
    }
项目:RetrofitAppArchitecture    文件:RequestControllableActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
@Override
public void onRequestCanceled(EventRequestCanceled cancel) {
    if (mFreedomRequestHandler.isFreedomRequest(cancel.mRequest)) {
        mFreedomRequestHandler.onRequestCanceled(cancel);
        return;
    }

    if (!isManagedRequest(cancel.mRequest)) return;

    mController.onRequestCanceled(cancel);
    handleRequestCanceled(cancel.mRequest);
}
项目:CodeWatch    文件:OnBoardActivity.java   
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onLogin(final LoginEvent loginEvent) {
    if (loginEvent.isLoginSuccess()) {
        setUpForFirstTimeUse();
    } else {
        displaySnackBar(R.string.login_failed, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                login(null);
            }
        });
    }
}
项目:greenrobot-examples    文件:MainActivity.java   
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN_ORDERED)
public void handleEvent(BlankBaseLibraryFragment.SampleEvent event) {
    String className = this.getClass().getSimpleName();
    String message = "#handleEvent: called for " + event.getClass().getSimpleName();
    Toast.makeText(this, className + message, Toast.LENGTH_SHORT).show();
    Log.d(className, message);

    // prevent event from re-delivering, like when leaving and coming back to app
    EventBus.getDefault().removeStickyEvent(event);
}
项目:ANNO1404-Warenrechner-App    文件:PopulationAdapter.java   
@Subscribe(threadMode = ThreadMode.MAIN)
@SuppressWarnings("unused")
public void onMessageEvent(PopulationResultEvent event) {
    this.populationData = event.getGame().population();
    this.game = event.getGame();
    notifyDataSetChanged();
}
项目:editor-sql    文件:DbTablesActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(ViewEvent event) {
    ViewEvent.EvenType type = event.getType();
    Bundle args = event.getArgs();

    switch (type) {
        case controlAdMob:
            mAdMobView.controlAdMob(args);
            break;

        case controlSqlPayTip:
            clearLongClick();
            break;
    }
}
项目:PeSanKita-android    文件:TransferControlView.java   
@Subscribe(sticky = true, threadMode = ThreadMode.ASYNC)
public void onEventAsync(final PartProgressEvent event) {
  if (this.slide != null && event.attachment.equals(this.slide.asAttachment())) {
    Util.runOnMain(new Runnable() {
      @Override
      public void run() {
        progressWheel.setInstantProgress(((float)event.progress) / event.total);
      }
    });
  }
}
项目:Alexa-Voice-Service    文件:MainActivity.java   
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(MessageEvent event){
    switch (event.event){
        case TokenHandler.FinishMainActivity:
            finish();
           break;
    }
}
项目:AssistantBySDK    文件:BaseEditDialog.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void showInputContent(ChatMsgEvent event) {
    if (event.textMsg != null) {
        if (event.textMsg instanceof ResponseMsg)
            return;
        inputText.setText(event.textMsg.text);
    }
}
项目:BookReader-master    文件:DownloadBookService.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public synchronized void addToDownloadQueue(DownloadQueue queue) {
    if (!TextUtils.isEmpty(queue.bookId)) {
        boolean exists = false;
        // 判断当前书籍缓存任务是否存在
        for (int i = 0; i < downloadQueues.size(); i++) {
            if (downloadQueues.get(i).bookId.equals(queue.bookId)) {
                LogUtils.e("addToDownloadQueue:exists");
                exists = true;
                break;
            }
        }
        if (exists) {
            post(new DownloadMessage(queue.bookId, "当前缓存任务已存在", false));
            return;
        }

        // 添加到下载队列
        downloadQueues.add(queue);
        LogUtils.e("addToDownloadQueue:" + queue.bookId);
        post(new DownloadMessage(queue.bookId, "成功加入缓存队列", false));
    }
    // 从队列顺序取出第一条下载
    if (downloadQueues.size() > 0 && !isBusy) {
        isBusy = true;
        downloadBook(downloadQueues.get(0));
    }
}