本文整理汇总了Java中org.greenrobot.eventbus.Subscribe类的典型用法代码示例。如果您正苦于以下问题:Java Subscribe类的具体用法?Java Subscribe怎么用?Java Subscribe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Subscribe类属于org.greenrobot.eventbus包,在下文中一共展示了Subscribe类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEventMainThread
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EventFocusCancel focusCancel){
if (mOverlayView != null) {
mOverlayView.setSelected(false);
}
postInvalidate();
}
示例2: onEvent
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
/**
* Listener for event that assets folder are now installed on the external storage.
* From that moment all content will be displayed from it.
*
* @param event event details
* @see AssetsInstalledEvent
* @see AssetsHelper
* @see EventBus
*/
@SuppressWarnings("unused")
@Subscribe
public void onEvent(final AssetsInstalledEvent event) {
// update stored application version
pluginInternalPrefs.setAppBuildVersion(VersionHelper.applicationVersionCode(cordova.getActivity()));
pluginInternalPrefs.setWwwFolderInstalled(true);
pluginInternalPrefsStorage.storeInPreference(pluginInternalPrefs);
isPluginReadyForWork = true;
PluginResult result = PluginResultHelper.pluginResultFromEvent(event);
sendMessageToDefaultCallback(result);
if (chcpXmlConfig.isAutoDownloadIsAllowed() &&
!UpdatesInstaller.isInstalling() && !UpdatesLoader.isExecuting()) {
fetchUpdate();
}
}
示例3: onError
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe(threadMode = ThreadMode.MAIN)
public void onError(final OnStatusError onStatusError) {
if (view != null) {
if (onStatusError.getRequest() != BaseActivity.REQUEST_CODE_SEND) {
return;
}
if (isUpdate) {
walletLoading.onError(onStatusError);
return;
}
view.hideProgressDialog();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (onStatusError.getMessage() == null) {
view.onError(view.getContext().getString(R.string.send_error_send));
} else {
view.onError(onStatusError.getMessage());
}
}
}, 500);
}
}
示例4: onEventMainThread
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(ViewEvent event) {
ViewEvent.EvenType type = event.getType();
Bundle args = event.getArgs();
if (!isInformation) {
switch (type) {
case sqlTabItemClick:
if (!isInformation) {
mClickPosition = (int) args.get(ViewEvent.Keys.SQL_TAB_ITEM_CLICK);
if (!isEdit) {
isEdit = true;
mToolbar.getMenu().clear();
mToolbar.inflateMenu(R.menu.sql_add_column_menu);
mToolBarButton.setVisibility(View.GONE);
}
}
break;
}
}
}
示例5: onEvent
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
/**
* Listener for event that some error happened during the update installation.
*
* @param event event information
* @see UpdateInstallationErrorEvent
* @see EventBus
* @see UpdatesInstaller
*/
@SuppressWarnings("unused")
@Subscribe
public void onEvent(UpdateInstallationErrorEvent event) {
Log.d("CHCP", "Failed to install");
PluginResult jsResult = PluginResultHelper.pluginResultFromEvent(event);
// notify js
if (installJsCallback != null) {
installJsCallback.sendPluginResult(jsResult);
installJsCallback = null;
}
sendMessageToDefaultCallback(jsResult);
rollbackIfCorrupted(event.error());
}
示例6: onEventMainThread
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Override
@Subscribe
public void onEventMainThread(LoginEvent event) {
switch (event.getEventType()) {
case LoginEvent.onSignInError:
onSignInError(event.getErrorMesage());
break;
case LoginEvent.onSignInSuccess:
onSignInSuccess(event.getLoggedUserEmail());
break;
case LoginEvent.onSignUpError:
onSignUpError(event.getErrorMesage());
break;
case LoginEvent.onSignUpSuccess:
onSignUpSuccess();
break;
case LoginEvent.onFailedToRecoverSession:
onFailedToRecoverSession();
break;
}
}
示例7: onStatusRefresh
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public void onStatusRefresh(StatusRefreshEvent statusRefreshEvent) {
int position = -1;
StatusRes statusRes = statusRefreshEvent.getStatusRes();
List<StatusRes> statusResList = mStatusAdapter.getAllData();
for (int i = 0; i < statusResList.size(); i++) {
if (statusResList.get(i).getId().equals(statusRes.getId())) {
position = i;
break;
}
}
if (position < 0) {
return;
}
if (statusRefreshEvent.getType().equals(StatusRefreshEvent.TYPE_DELETE_STATUS)) {
mStatusAdapter.remove(position);
} else if (statusRefreshEvent.getType().equals(StatusRefreshEvent.TYPE_FAVORITE_STATUS)) {
mStatusAdapter.update(statusRes, position);
}
}
示例8: onEventMainThread
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Override
@Subscribe
public void onEventMainThread(RecipeListEvent event) {
if (this.view != null) {
switch (event.getType()) {
case RecipeListEvent.READ_EVENT:
view.setRecipes(event.getRecipeList());
break;
case RecipeListEvent.UPDATE_EVENT:
view.recipeUpdated();
break;
case RecipeListEvent.DELETE_EVENT:
Recipe recipe = event.getRecipeList().get(0);
view.recipeDeleted(recipe);
break;
}
}
}
示例9: onMergedEvent
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMergedEvent(EventMergeFinish mergeService) {
ProgressBarHelper.getInstance(true).dismiss();
try {
mViewDrawableOverlay.setVisibility(View.GONE);
ViewAnimator.animate(mGifImageView).fadeIn().accelerate().duration(600).start();
mGifImageView.setVisibility(View.VISIBLE);
GifDrawable gifFromBytes = new GifDrawable(mergeService.getGifPath());
gifFromBytes.setLoopCount(0xFFFF);
mGifImageView.setImageDrawable(gifFromBytes);
mStickerTextDownLoadDialog.dismiss();
} catch (IOException e) {
e.printStackTrace();
}
String mergePath = mergeService.getGifPath();
EventBus.getDefault().post(new EventStartNewThread(true, mergePath));
}
示例10: onQuerySummit
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe
public void onQuerySummit(QueryEvent event) {
if (!isShown()) {
return;
}
if (event == QueryEvent.CLEAR) {
mWebView.clearMatches();
mPreviousQuery = null;
return;
}
if (event.isFindForward()) {
mWebView.findNext(false);
return;
}
if (event.getQuery().equals(mPreviousQuery)) {
mWebView.findNext(true);
return;
}
mWebView.findAllAsync(event.getQuery());
mPreviousQuery = event.getQuery();
}
示例11: onEvent
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
/**
* Listener for event that there is no update available at the moment.
* We are as fresh as possible.
*
* @param event event information
* @see EventBus
* @see NothingToUpdateEvent
* @see UpdatesLoader
*/
@SuppressWarnings("unused")
@Subscribe
public void onEvent(NothingToUpdateEvent event) {
Log.d("CHCP", "Nothing to update");
PluginResult jsResult = PluginResultHelper.pluginResultFromEvent(event);
//notify JS
if (downloadJsCallback != null) {
downloadJsCallback.sendPluginResult(jsResult);
downloadJsCallback = null;
}
sendMessageToDefaultCallback(jsResult);
}
示例12: onMessageEvent
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(ViewEvent event) {
Bundle bundle = new Bundle();
switch (event.getType()){
case gotoFileClickPosition:
FileData fileData = (FileData) event.getArgs().getSerializable(ViewEvent.Keys.GOTO_PATH);
bundle.putSerializable(Constant.FILE_DATA_TYPE, FileDataType.gotoPath);
bundle.putString(Constant.GOTO_PATH,fileData.getPath());
items.clear();
items.add(new HeaderData(fileData.getPath()));
break;
case backPath:
HeaderData headerData = (HeaderData) event.getArgs().getSerializable(ViewEvent.Keys.BACK_PATH_HEADER);
if(rootPath.equals(headerData.getPath())){
Toasty.info(context,"当前为SD卡根目录",Toast.LENGTH_SHORT,true).show();
return;
}
bundle.putSerializable(Constant.FILE_DATA_TYPE, FileDataType.backPath);
bundle.putString(Constant.BACK_PATH,headerData.getPath());
String parentPath = FileUtil.getParentPath(headerData.getPath());
items.clear();
items.add(new HeaderData(parentPath));
break;
}
initLoader(bundle);
}
示例13: onEventMainThread
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EventStartMainThread mainThread) {
mMergePath = mainThread.getPath();
if (mainThread.isCreate()) {
ProgressBarHelper.getInstance(false).dismiss();
ViewAnimator.animate(mVoiceIndicatorView).fadeOut().accelerate().duration(600).start();
ViewAnimator.animate(mLlShare).fadeIn().accelerate().duration(600)
.onStart(() -> {
mViewPager.setVisibility(View.GONE);
mLlShare.setVisibility(View.VISIBLE);
})
.start();
} else {
ViewAnimator.animate(mVoiceIndicatorView).fadeIn().accelerate().duration(600).start();
ViewAnimator.animate(mLlShare).fadeOut().accelerate().duration(600)
.onStop(() -> {
mViewPager.setVisibility(View.VISIBLE);
mLlShare.setVisibility(View.GONE);
})
.start();
}
}
示例14: onMessageEvent
import org.greenrobot.eventbus.Subscribe; //导入依赖的package包/类
/**
* Used by EventBus
* Called when a Publisher send a state.
* @param stateEvent
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(StateEvent stateEvent) {
switch (stateEvent.getState()) {
case CONNECTED: {
Pandwarf.getInstance().setConnected(true);
toastShow("Device Opened...");
break;
}
case DISCONNECTED: {
toastShow("Closing device...");
Pandwarf.getInstance().setConnected(false);
break;
}
}
}
示例15: onRecordUpdateEvent
import org.greenrobot.eventbus.Subscribe; //导入依赖的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;
}
}