/** * 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; } } }
@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); } }
@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(); } }
@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); } } } }
@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); }
/** * 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); }
@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(); } }
/** * 话筒状态更新处理 **/ @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; } }
/** * 导航相关指令处理 **/ @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; } }
@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(); } }
@Subscribe(threadMode = ThreadMode.MAIN) @SuppressWarnings("unused") public void onMessageEvent(ChainsResultEvent event) { if (event.isGame(game)) { this.chainsData = event.getResult(); notifyDataSetChanged(); } }
@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(); }
/** * Responds to published events * * @param param */ @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEventPublished(Series param) { if(!isRemoving() && model == null) { model = param; updateUI(); } }
@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(); } }
@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); }
@Subscribe(threadMode = ThreadMode.MAIN) public void initCategoryList(SelectionEvent event) { if (getUserVisibleHint()) { mRecyclerView.setRefreshing(true); sort = event.sort; onRefresh(); } }
@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); }
@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); }
@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 { } }
@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(); } }
@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; } }
@Subscribe(threadMode = ThreadMode.MAIN) public void downloadMessage(final DownloadMessage msg) { mRecyclerView.setTipViewText(msg.message); if (msg.isComplete) { mRecyclerView.hideTipView(2200); } }
@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); } }); } }
@Subscribe(threadMode = ThreadMode.MAIN) public void initCategoryList(SelectionEvent event) { mRecyclerView.setRefreshing(true); sort = event.sort; distillate = event.distillate; onRefresh(); }
@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()); }
@Subscribe(threadMode = ThreadMode.MAIN) public void onEventMainThread(EventShare share) { if (share.isShare()) ProgressBarHelper.getInstance(true).show(getActivity(), "正在进行分享, 请稍后"); else ProgressBarHelper.getInstance(true).dismiss(); }
/** * Search page fragments * * @param query */ @Subscribe(threadMode = ThreadMode.MAIN) @Override public void update(String query) { if(mAdapter != null) { mAdapter.getFilter().filter(query); } }
@Subscribe(threadMode = ThreadMode.MAIN) @Keep public void onPrivateMessageEvent(PrivateMessageEvent event) { if (presenter.getType() == DialogsType.PRIVATE_CHAT) { presenter.processPrivateMessage(event.getMessage()); } }
@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; }
@Subscribe(threadMode = ThreadMode.MAIN) public void onEncodeStop (EventBusConstants.ScreenRecodeStop stop) { // if (encoder != null) { // encoder.stop(); // } isNeedSendData = false; }
@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); }
@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); } }); } }
@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); }
@Subscribe(threadMode = ThreadMode.MAIN) @SuppressWarnings("unused") public void onMessageEvent(PopulationResultEvent event) { this.populationData = event.getGame().population(); this.game = event.getGame(); notifyDataSetChanged(); }
@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; } }
@Subscribe(threadMode = ThreadMode.BACKGROUND) public void onMessageEvent(MessageEvent event){ switch (event.event){ case TokenHandler.FinishMainActivity: finish(); break; } }
@Subscribe(threadMode = ThreadMode.MAIN) public void showInputContent(ChatMsgEvent event) { if (event.textMsg != null) { if (event.textMsg instanceof ResponseMsg) return; inputText.setText(event.textMsg.text); } }
@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)); } }