本文整理匯總了Java中org.greenrobot.eventbus.ThreadMode類的典型用法代碼示例。如果您正苦於以下問題:Java ThreadMode類的具體用法?Java ThreadMode怎麽用?Java ThreadMode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ThreadMode類屬於org.greenrobot.eventbus包,在下文中一共展示了ThreadMode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMessageEvent
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
/**
* 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;
}
}
}
示例2: onObdJob
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@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);
}
}
示例3: onMessageEvent
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@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();
}
}
示例4: downloadMessage
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@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);
}
}
}
}
示例5: onEventMainThread
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@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);
}
示例6: updateVoiceState
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
/**
* 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);
}
示例7: handleEvent
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@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();
}
}
示例8: onRecordUpdateEvent
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
/**
* 話筒狀態更新處理
**/
@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;
}
}
示例9: onNetWorkEvent
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
/**
* 導航相關指令處理
**/
@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;
}
}
示例10: onEvent
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@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();
}
}
示例11: onMessageEvent
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@Subscribe(threadMode = ThreadMode.MAIN)
@SuppressWarnings("unused")
public void onMessageEvent(ChainsResultEvent event) {
if (event.isGame(game)) {
this.chainsData = event.getResult();
notifyDataSetChanged();
}
}
示例12: onEventScoreLoaded
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@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();
}
示例13: onEventPublished
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
/**
* Responds to published events
*
* @param param
*/
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventPublished(Series param) {
if(!isRemoving() && model == null) {
model = param;
updateUI();
}
}
示例14: refreshData
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@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);
}
示例15: initCategoryList
import org.greenrobot.eventbus.ThreadMode; //導入依賴的package包/類
@Subscribe(threadMode = ThreadMode.MAIN)
public void initCategoryList(SelectionEvent event) {
if (getUserVisibleHint()) {
mRecyclerView.setRefreshing(true);
sort = event.sort;
onRefresh();
}
}