de.greenrobot.event.EventBusException Java Examples

The following examples show how to use de.greenrobot.event.EventBusException. 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: AppDisplayFragment.java    From ApkTrack with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onResume()
{
    super.onResume();

    // Register for sticky events in a separate thread.
    // When registering, the latest stiky is also delivered. It may contain many events to
    // process, which is why this is kept out of the UI thread.
    new Thread(new Runnable() {
        @Override
        public void run()
        {
            try  {
                EventBus.getDefault().registerSticky(AppDisplayFragment.this, 1);
            }
            catch (EventBusException ignored) {} // The fragment may already be registered.
        }
    }).start();

}
 
Example #2
Source File: BaseMvpPresenter.java    From XiaoxiaZhihu with Apache License 2.0 5 votes vote down vote up
public void registerEventBusListener(Object object) {
    if (getEventBus() != null) {
        try {
            getEventBus().register(object);
        } catch (EventBusException eventBusException) {
            // 如果object没有任何onEvent等订阅,会导致EventBusException,此处try-catch防止崩溃
        }
    }
}
 
Example #3
Source File: OPFIab.java    From OPFIab with Apache License 2.0 5 votes vote down vote up
static void register(@NonNull final Object subscriber) {
    if (!EVENT_BUS.isRegistered(subscriber)) {
        try {
            EVENT_BUS.register(subscriber);
        } catch (EventBusException exception) {
            OPFLog.d("", exception);
        }
    }
}
 
Example #4
Source File: USBHIDTerminal.java    From USBHIDTerminal with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	try {
		eventBus = EventBus.builder().logNoSubscriberMessages(false).sendNoSubscriberEvent(false).installDefaultEventBus();
	} catch (EventBusException e) {
		eventBus = EventBus.getDefault();
	}
	sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
	sharedPreferences.registerOnSharedPreferenceChangeListener(listener);
	initUI();
}