Java Code Examples for org.greenrobot.eventbus.EventBus#register()

The following examples show how to use org.greenrobot.eventbus.EventBus#register() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PushChallengeRequest.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@WorkerThread
private Optional<String> requestAndReceiveChallengeBlocking() {
  EventBus eventBus = EventBus.getDefault();

  eventBus.register(this);
  try {
    accountManager.requestPushChallenge(fcmToken, e164number);

    latch.await(timeoutMs, TimeUnit.MILLISECONDS);

    return Optional.fromNullable(challenge.get());
  } catch (InterruptedException | IOException e) {
    Log.w(TAG, "Error getting push challenge", e);
    return Optional.absent();
  } finally {
    eventBus.unregister(this);
  }
}
 
Example 2
Source File: ActionModeSupport.java    From android-auto-call-recorder with MIT License 6 votes vote down vote up
public ActionModeSupport
        (@ApplicationContext Context mContext,
         EventBus mEventBus,
         Constant mConstant,
         String mTitle,
         boolean mIsForBroadcast,
         Toolbar mToolbar,
         RecordsAdapter mAdapter) {
    this.mEventBus = mEventBus;
    this.mTitle = mTitle;
    this.mIsForBroadcast = mIsForBroadcast;
    this.mToolbar = mToolbar;
    this.mAdapter = mAdapter;

    mEventBus.register(this);
}
 
Example 3
Source File: ActionModeSupport.java    From android-auto-call-recorder with MIT License 5 votes vote down vote up
public ActionModeSupport
        (@ApplicationContext Context mContext,
         EventBus mEventBus,
         Constant mConstant,
         String mTitle,
         boolean mIsForBroadcast) {
    this.mContext = mContext;
    this.mEventBus = mEventBus;
    this.mConstant = mConstant;
    this.mTitle = mTitle;
    this.mIsForBroadcast = mIsForBroadcast;

    mEventBus.register(this);
}
 
Example 4
Source File: ActionModeSupport.java    From android-auto-call-recorder with MIT License 5 votes vote down vote up
public ActionModeSupport(String mTitle,
                         EventBus mEventBus,
                         boolean mIsForBroadcast,
                         ActionBar mActionBar,
                         Toolbar mToolbar,
                         RecordsAdapter mAdapter) {
    this.mEventBus = mEventBus;
    this.mTitle = mTitle;
    this.mIsForBroadcast = mIsForBroadcast;
    this.mActionBar = mActionBar;
    this.mToolbar = mToolbar;
    this.mAdapter = mAdapter;

    mEventBus.register(this);
}
 
Example 5
Source File: EventBusUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 注册 EventBus
 * @param subscriber 订阅者
 */
public static void register(final Object subscriber) {
    EventBus eventBus = EventBus.getDefault();
    if (!eventBus.isRegistered(subscriber)) {
        eventBus.register(subscriber);
    }
}
 
Example 6
Source File: Stream.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
/**
 * Register a function to current stream.
 * @param streamReceiver the function that receives stream items
 */
public synchronized void register(Function<? extends Stream, ?> streamReceiver) {
    if (this.receivers.size() >= this.receiverCount) {
        Logging.warn("Unknown StreamProvider trying to subscribe to stream!");
        return;
    }
    EventBus eventBus = new EventBus();
    eventBus.register(streamReceiver);
    this.receivers.add(streamReceiver);
    this.eventBuses.add(eventBus);
    this.numSents.add(0);

    Stream.this.syncItems();
}
 
Example 7
Source File: AsyncFunction.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
public final Tout apply(UQI uqi, Tin input) {
    this.uqi = uqi;
    this.input = input;
    this.output = this.init(uqi, input);
    EventBus tempBus = new EventBus();
    tempBus.register(this);
    tempBus.post(new Object());
    return this.output;
}
 
Example 8
Source File: ModelDetailActivity.java    From Synapse with Apache License 2.0 5 votes vote down vote up
private void registerEventBus() {
    final EventBus bus = Global.getInstance().getBus();

    if (mIntentType == IS_TRAINING
            && !bus.isRegistered(this)) {
        bus.register(this);
    }
}
 
Example 9
Source File: SpectrumPalette.java    From Muzesto with GNU General Public License v3.0 5 votes vote down vote up
private void init() {
    mEventBus = new EventBus();
    mEventBus.register(this);

    mColorItemDimension = getResources().getDimensionPixelSize(com.thebluealliance.spectrum.R.dimen.color_item_small);
    mColorItemMargin = getResources().getDimensionPixelSize(com.thebluealliance.spectrum.R.dimen.color_item_margins_small);

    setOrientation(LinearLayout.VERTICAL);
}
 
Example 10
Source File: ServiceProvider.java    From Anecdote with Apache License 2.0 5 votes vote down vote up
public void register(EventBus eventBus) {
    for (Map.Entry<String, AnecdoteService> entry : mAnecdoteServices.entrySet()) {
        eventBus.register(entry.getValue());
    }
    eventBus.register(mWebsiteApiService);
    eventBus.register(mSocialService);
    mSocialService.register();
}
 
Example 11
Source File: HotCodePushPlugin.java    From cordova-hot-code-push with MIT License 5 votes vote down vote up
@Override
public void onStart() {
    super.onStart();

    final EventBus eventBus = EventBus.getDefault();
    if (!eventBus.isRegistered(this)) {
        eventBus.register(this);
    }

    // ensure that www folder installed on external storage;
    // if not - install it
    isPluginReadyForWork = isPluginReadyForWork();
    if (!isPluginReadyForWork) {
        dontReloadOnStart = true;
        installWwwFolder();
        return;
    }

    // reload only if we on local storage
    if (!dontReloadOnStart) {
        dontReloadOnStart = true;
        redirectToLocalStorageIndexPage();
    }

    // install update if there is anything to install
    if (chcpXmlConfig.isAutoInstallIsAllowed() &&
            !UpdatesInstaller.isInstalling() &&
            !UpdatesLoader.isExecuting() &&
            !TextUtils.isEmpty(pluginInternalPrefs.getReadyForInstallationReleaseVersionName())) {
        installUpdate(null);
    }
}
 
Example 12
Source File: AbsTrackHandler.java    From Synapse with Apache License 2.0 4 votes vote down vote up
void register(@NonNull EventBus bus) {
    bus.register(this);
}