public PerfTestEventBus(Context context, TestParams params) { super(context, params); eventBus = EventBus.builder().eventInheritance(params.isEventInheritance()).addIndex(new MyEventBusIndex()) .ignoreGeneratedIndex(params.isIgnoreGeneratedIndex()).build(); subscribers = new ArrayList<Object>(); eventCount = params.getEventCount(); expectedEventCount = eventCount * params.getSubscriberCount(); subscriberClass = getSubscriberClassForThreadMode(); }
/** Ensures the index is actually used and no reflection fall-back kicks in. */ @Test public void testManualIndexWithoutAnnotation() { SubscriberInfoIndex index = new SubscriberInfoIndex() { @Override public SubscriberInfo getSubscriberInfo(Class<?> subscriberClass) { Assert.assertEquals(EventBusIndexTest.class, subscriberClass); SubscriberMethodInfo[] methodInfos = { new SubscriberMethodInfo("someMethodWithoutAnnotation", String.class) }; return new SimpleSubscriberInfo(EventBusIndexTest.class, false, methodInfos); } }; EventBus eventBus = EventBus.builder().addIndex(index).build(); eventBus.register(this); eventBus.post("Yepp"); eventBus.unregister(this); Assert.assertEquals("Yepp", value); }
@Before public void overwriteEventBus() throws Exception { eventBus = EventBus.builder().addIndex(new InJarIndex()).build(); } }
@Before public void setUp() throws Exception { eventBus = EventBus.builder().eventInheritance(false).addIndex(new EventBusTestsIndex()).build(); } }
/** Ensures the index is actually used and no reflection fall-back kicks in. */ @Test public void testManualIndexWithoutAnnotation() { SubscriberInfoIndex index = new SubscriberInfoIndex() { @Override public SubscriberInfo getSubscriberInfo(Class<?> subscriberClass) { Assert.assertEquals(EventBusIndexTest.class, subscriberClass); SubscriberMethodInfo[] methodInfos = { new SubscriberMethodInfo("someMethodWithoutAnnotation", String.class) }; return new SimpleSubscriberInfo(EventBusIndexTest.class, false, methodInfos); } }; EventBus eventBus = EventBus.builder().addIndex(index).build(); eventBus.register(this); eventBus.post("Yepp"); eventBus.unregister(this); Assert.assertEquals("Yepp", value); }
@Override public void onCreate() { super.onCreate(); context = this; EventBus.builder().addIndex(new EventBusIndex()).build(); // hack for devices with hw options button try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField(S_HAS_PERMANENT_MENU_KEY); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { logger.error(e.getMessage().replace("\n", " ")); } }
@Override public void onCreate() { super.onCreate(); EventBus.builder().addIndex(new MyEventBusIndex()).installDefaultEventBus(); Intent serviceIntent = new Intent(getApplicationContext(), MasterBrainService.class); startService(serviceIntent); AndroidGraphicFactory.createInstance(this); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); final float fs = Float.valueOf(preferences.getString(SETTING_SCALE, Float.toString(DisplayModel.getDefaultUserScaleFactor()))); if (fs != DisplayModel.getDefaultUserScaleFactor()) { DisplayModel.setDefaultUserScaleFactor(fs); } } }
@Provides @PerApplication protected EventBus provideEventbus() { return EventBus.builder().addIndex(new org.owntracks.android.EventBusIndex()).sendNoSubscriberEvent(false).logNoSubscriberMessages(false).build(); }
@Override public void onCreate() { super.onCreate(); if(BuildConfig.DEBUG) Stetho.initializeWithDefaults(this); EventBus.builder() .sendNoSubscriberEvent(false) .sendSubscriberExceptionEvent(false) .throwSubscriberException(BuildConfig.DEBUG) .addIndex(new EventBusIndex()) .installDefaultEventBus(); Settings.init(this); settings = new Settings(this); settings.initPreferences(); new EventProcessor(this).start(); DbConnection.setContext(this); instance = this; }