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

项目:exciting-app    文件:MyImageViewDrawableOverlay.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EventFocusCancel focusCancel){
    if (mOverlayView != null) {
        mOverlayView.setSelected(false);
    }
    postInvalidate();
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * 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();
    }
}
项目:atlant-android    文件:SendPresenterImpl.java   
@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);

  }
}
项目:editor-sql    文件:SqlCreateTableActivity.java   
@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;
        }
    }

}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * 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());
}
项目:androidadvanced    文件:LoginPresenterImpl.java   
@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;
    }
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Listener for event that some error has happened during the update download process.
 *
 * @param event event information
 * @see EventBus
 * @see UpdateDownloadErrorEvent
 * @see UpdatesLoader
 */
@SuppressWarnings("unused")
@Subscribe
public void onEvent(UpdateDownloadErrorEvent event) {
    Log.d("CHCP", "Failed to update");

    final ChcpError error = event.error();
    if (error == ChcpError.LOCAL_VERSION_OF_APPLICATION_CONFIG_NOT_FOUND || error == ChcpError.LOCAL_VERSION_OF_MANIFEST_NOT_FOUND) {
        Log.d("CHCP", "Can't load application config from installation folder. Reinstalling external folder");
        installWwwFolder();
    }

    PluginResult jsResult = PluginResultHelper.pluginResultFromEvent(event);

    // notify JS
    if (downloadJsCallback != null) {
        downloadJsCallback.sendPluginResult(jsResult);
        downloadJsCallback = null;
    }

    sendMessageToDefaultCallback(jsResult);

    rollbackIfCorrupted(event.error());
}
项目:xifan    文件:HomeFragment.java   
@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);
    }
}
项目:androidadvanced    文件:RecipeListPresenterImpl.java   
@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;
        }
    }

}
项目:exciting-app    文件:VoiceMainActivity.java   
@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));
}
项目:Auto.js    文件:DocsFragment.java   
@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();
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * 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);
}
项目:FileBrowser    文件:FileFragment.java   
@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);
}
项目:exciting-app    文件:TheHostVoiceMenuFragment.java   
@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();
    }
}
项目:PandwarfDefenderProject    文件:Main2Activity.java   
/**
 * 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;
        }
    }
}
项目: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;
    }
}
项目:RetrofitAppArchitecture    文件:BaseFragmentForSupport.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);
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Listener for event that we successfully installed new update.
 *
 * @param event event information
 * @see EventBus
 * @see UpdateInstalledEvent
 * @see UpdatesInstaller
 */
@SuppressWarnings("unused")
@Subscribe
public void onEvent(UpdateInstalledEvent event) {
    Log.d("CHCP", "Update is installed");

    final ContentConfig newContentConfig = event.applicationConfig().getContentConfig();

    // update preferences
    pluginInternalPrefs.setPreviousReleaseVersionName(pluginInternalPrefs.getCurrentReleaseVersionName());
    pluginInternalPrefs.setCurrentReleaseVersionName(newContentConfig.getReleaseVersion());
    pluginInternalPrefs.setReadyForInstallationReleaseVersionName("");
    pluginInternalPrefsStorage.storeInPreference(pluginInternalPrefs);

    fileStructure = new PluginFilesStructure(cordova.getActivity(), newContentConfig.getReleaseVersion());

    final PluginResult jsResult = PluginResultHelper.pluginResultFromEvent(event);

    if (installJsCallback != null) {
        installJsCallback.sendPluginResult(jsResult);
        installJsCallback = null;
    }

    sendMessageToDefaultCallback(jsResult);

    // reset content to index page
    handler.post(new Runnable() {
        @Override
        public void run() {
            HotCodePushPlugin.this.redirectToLocalStorageIndexPage();
        }
    });

    cleanupFileSystemFromOldReleases();
}
项目:phonk    文件:FilePreviewerFragment.java   
@Subscribe
public void onEventMainThread(Events.EditorEvent e) {
    if (e.getAction().equals(Events.EDITOR_FILE_PREVIEW)) {
        ProtoFile f = e.getProtofile();
        String type = e.getPreviewType();

        unloadAll();

        if (type.equals("image")) loadImage(f.getFullPath());
        else if (type.equals("video")) loadVideo(f.path);
        else if (type.equals("sound")) loadSound(f.path);
    }
}
项目:android-movies-app    文件:MoviesFragment.java   
@Subscribe(sticky = true)
public void onEvent(UpdateFavoritesEvent event) {
    if (fragType == Type.FAVORITES) {
        EventBus.getDefault().removeStickyEvent(UpdateFavoritesEvent.class);
        onRefresh();
    }
}
项目:Howl    文件:ChatFragment.java   
@Subscribe //ben sildim
public void onPushNotificationEvent(PushNotificationEvent pushNotificationEvent) {
    if (mChatRecyclerAdapter == null || mChatRecyclerAdapter.getItemCount() == 0) {
        mChatPresenter.getMessage(FirebaseAuth.getInstance().getCurrentUser().getUid(),
                pushNotificationEvent.getUid());

    }

}
项目: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);
    }
}
项目:healthgo    文件:StepThread.java   
@Subscribe
public void subscribeActivity(Boolean f) {
    if (f)
        EventBus.getDefault().post(numStpes);
    else
        save(DateTimeHelper.getToday(),numStpes);
    isActivity = f;
}
项目:FanChat    文件:AddFriendPresenterImpl.java   
@Subscribe(threadMode = ThreadMode.MAIN,sticky = true)
public void onMessageEvent(String event) {
    /* Do something */
    long time = System.currentTimeMillis();
    Log.d(TAG, "searchFriend: "+time);
    Log.d(TAG, "onMessageEvent: ");
}
项目:GitHub    文件:BookReviewFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void initCategoryList(SelectionEvent event) {
    mRecyclerView.setRefreshing(true);
    sort = event.sort;
    type = event.type;
    distillate = event.distillate;
    start = 0;
    mPresenter.getBookReviewList(sort, type, distillate, start, limit);
}
项目: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();
}
项目:GitHub    文件:SubjectFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void initCategoryList(TagEvent event) {
    currendTag = event.tag;
    if (getUserVisibleHint()) {
        mPresenter.getBookLists(duration, sort, 0, limit, currendTag, SettingManager.getInstance().getUserChooseSex());
    }
}
项目:streaminglib    文件:RtspServer.java   
@Subscribe(threadMode = ThreadMode.ASYNC)
public void handleEvent(RtspServerStreamEvent.StreamAvailable event) {
    Log.d(TAG, "handleEvent: RtspServerStreamEvent.StreamAvailable");
    RtpMedia m = event.getRtpMedia();
    m.control = "trackID=" + nextTrackId++;
    media.add(m);
}
项目:ZeroKit-Android-Sample    文件:MainActivity.java   
@Subscribe
@SuppressWarnings("unused")
public void onEvent(CopyEncryptedTextMessage message) {
    ClipboardManager clipboard = (ClipboardManager) getSystemService(Activity.CLIPBOARD_SERVICE);
    ClipData clip = ClipData.newPlainText("Encrypted text", message.getEncryptedMessage());
    clipboard.setPrimaryClip(clip);
    showMessage("Encrypted text copied to clipboard");
}
项目:SOS-The-Healthcare-Companion    文件:ContactFragment.java   
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEventMainThread(ContactsLoaded event) {
    EventBus.getDefault().removeStickyEvent(event);

    mContacts = event.getContacts();
    mFilteredContacts = mContacts;
    mAdapter.setData(mFilteredContacts);

    updateEmptyViewVisibility(mContacts);
}
项目:GitHub    文件:BookDetailDiscussionFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void initCategoryList(SelectionEvent event) {
    if (getUserVisibleHint()) {
        mRecyclerView.setRefreshing(true);
        sort = event.sort;
        onRefresh();
    }
}
项目:RetrofitAppArchitecture    文件:BaseFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
@Override
public void onNetRequestError(EventNetError error) {
    if (mFreedomRequestHandler.isFreedomRequest(error.mRequest)) {
        mFreedomRequestHandler.onNetRequestError(error);
        return;
    }

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

    mController.onNetRequestError(error);
    handleNetRequestError(error.mRequest, error.mRB);
}
项目:AssistantBySDK    文件:ChatListFragment.java   
/**
 * 合成事件响应
 **/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onSynthesizeEvent(SynthesizeEvent event) {
    switch (event.getState()) {
        case SynthesizeEvent.SYNTH_START:
            chatListView.post(new Runnable() {
                @Override
                public void run() {
                    int respViewPosition = chatListApdater.getLastRespViewPosition();
                    if (respViewPosition != -1) {
                        View itemView = linearLayoutManager.findViewByPosition(respViewPosition);
                        if (itemView != null) {
                            RspMsgItemView resp = (RspMsgItemView) itemView.findViewById(R.id.resp_view);
                            startSpeakerAnimation(resp);
                        }
                    }
                }
            });
            break;
        case SynthesizeEvent.SYNTH_END:
            stopSpeakerAnimation();
            break;
        default:
            showSynthErrorDialog();
            break;
    }
}
项目:Auto.js    文件:MyScriptListFragment.java   
@Subscribe
public void onQuerySummit(QueryEvent event) {
    if (!isShown()) {
        return;
    }
    if (event == QueryEvent.CLEAR) {
        mScriptFileList.setFilter(null);
        return;
    }
    String query = event.getQuery();
    mScriptFileList.setFilter((file -> file.getSimplifiedName().contains(query)));
}
项目: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));
    }
}
项目:BookReader-master    文件:SubjectFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void initCategoryList(TagEvent event) {
    currendTag = event.tag;
    if (getUserVisibleHint()) {
        mPresenter.getBookLists(duration, sort, 0, limit, currendTag, SettingManager.getInstance().getUserChooseSex());
    }
}
项目:TextReader    文件:RecommendFragment.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void downloadMessage(final DownloadMessage msg) {
    mRecyclerView.setTipViewText(msg.message);
    if (msg.isComplete) {
        mRecyclerView.hideTipView(2200);
    }
}
项目:AppChooser    文件:FileInfosActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void onFileInfo(FileInfo fileInfo) {
    if (fileInfo.isFile()) {
        showFile(fileInfo);
    } else {
        showDirectory(fileInfo, OPERATION_CLICK_ITEM);
    }
}
项目:pc-android-controller-android    文件:ScreenRecodeService.java   
@Subscribe(threadMode = ThreadMode.MAIN)
    public void onEncodeStart (EventBusConstants.ScreenRecodeStart start) {
//        if (encoder != null) {
//            encoder.start();
//        }
//        sendData1();
        isNeedSendData = true;
    }
项目:grblcontroller    文件:MainActivity.java   
@Subscribe(threadMode = ThreadMode.MAIN)
public void  onGrblErrorEvent(GrblErrorEvent event){
    if(event.getErrorCode() == 15){
        jogCommandQueue.clear();
    }
    consoleLogger.setMessages(event.toString());
}