com.squareup.otto.ThreadEnforcer Java Examples

The following examples show how to use com.squareup.otto.ThreadEnforcer. 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: RssApplication.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        bus = new Bus(ThreadEnforcer.ANY);

        list = new ArrayList<>();
        StringBuffer buffer = new StringBuffer();
        try (BufferedReader input = new BufferedReader(
                new InputStreamReader(
                        openFileInput(RSS_FILE)))) {
            String line;
            while ((line = input.readLine()) != null) {
                buffer.append(line);
            }
        } catch (Exception ex) {
// do nothing
        }
        if (buffer!=null && buffer.length()>0 )
        {
            Gson gson = new Gson();
            Type type = new TypeToken<List<RssItem>>() {}.getType();
            List<RssItem> fromJson = gson.fromJson(buffer.toString(), type);
            list.addAll(fromJson);
        }
    }
 
Example #2
Source File: Events.java    From ploggy with GNU General Public License v3.0 5 votes vote down vote up
public static void initialize() {
    mBus = new Bus(ThreadEnforcer.MAIN);
    mHandler = new Handler();

    // Activity and fragment lifecycle events make it difficult to reliably
    // make register and unregister calls in a 1-to-1 way. So we're going
    // to make sure that things only get registered once and unregistered if
    // they're actually registered.
    mRegisteredObjects = new HashSet<Object>();
}
 
Example #3
Source File: InternetConnectionChangeReceiverTest.java    From NetworkEvents with Apache License 2.0 5 votes vote down vote up
@Before public void setUp() throws Exception {
  this.busWrapper = new OttoBusWrapper(new Bus(ThreadEnforcer.ANY));
  Logger logger = Mockito.mock(Logger.class);
  Context context = Mockito.mock(Context.class);
  this.receiver = new InternetConnectionChangeReceiver(busWrapper, logger, context);
  this.connectivityChangeEvents = new ArrayList<>();
}
 
Example #4
Source File: NetworkConnectionChangeReceiverTest.java    From NetworkEvents with Apache License 2.0 5 votes vote down vote up
@Before public void setUp() throws Exception {
  this.busWrapper = new OttoBusWrapper(new Bus(ThreadEnforcer.ANY));
  Logger logger = Mockito.mock(Logger.class);
  Context context = Mockito.mock(Context.class);
  OnlineChecker onlineChecker = Mockito.mock(OnlineChecker.class);
  this.receiver = new NetworkConnectionChangeReceiver(busWrapper, logger, context, onlineChecker);
  this.connectivityChangeEvents = new ArrayList<>();
}
 
Example #5
Source File: DaggerModule.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
/**
 * 提供全局单例的event bus
 */
@Provides
@Singleton
public Bus provideBus() {
    // our event bus running on any thread
    return new Bus(ThreadEnforcer.ANY);
}
 
Example #6
Source File: BaseApp.java    From masterpassword with GNU General Public License v3.0 4 votes vote down vote up
public void onCreate() {
    super.onCreate();
    instance = this;
    bus = new Bus(ThreadEnforcer.ANY);
}
 
Example #7
Source File: ChatBus.java    From meatspace-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public ChatBus() {
    // events will be fired on the main thread
    this.bus = new Bus(ThreadEnforcer.MAIN);
}
 
Example #8
Source File: UIBus.java    From meatspace-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public UIBus() {
    // events will be fired on the main thread
    this.bus = new Bus(ThreadEnforcer.MAIN);
}
 
Example #9
Source File: AndroidModule.java    From JayPS-AndroidApp with MIT License 4 votes vote down vote up
@Provides @Singleton
Bus providesBus() { return new MainThreadBus(new Bus(ThreadEnforcer.ANY)); }
 
Example #10
Source File: BleEventBus.java    From Android-BleEventAdapter with Apache License 2.0 4 votes vote down vote up
public BleEventBus(ThreadEnforcer enforcer) {
    super(enforcer, "Indy-Ble-LowLevel");
}
 
Example #11
Source File: WifiSignalStrengthChangeReceiverTest.java    From NetworkEvents with Apache License 2.0 4 votes vote down vote up
@Before public void setUp() throws Exception {
  this.busWrapper = new OttoBusWrapper(new Bus(ThreadEnforcer.ANY));
  Logger logger = Mockito.mock(Logger.class);
  Context context = Mockito.mock(Context.class);
  this.receiver = new WifiSignalStrengthChangeReceiver(busWrapper, logger, context);
}
 
Example #12
Source File: EventBusProvider.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private EventBusProvider() {
    mBus = new Bus(ThreadEnforcer.MAIN);
}
 
Example #13
Source File: AndroidBus.java    From tapchat-android with Apache License 2.0 4 votes vote down vote up
public AndroidBus() {
    super(ThreadEnforcer.MAIN);
}
 
Example #14
Source File: PaletteColorModule.java    From MaterialDesignColorPalette with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
public Bus provideBus() {
    return new Bus(ThreadEnforcer.ANY);
}
 
Example #15
Source File: EventBus.java    From GameOfLife with MIT License 4 votes vote down vote up
private EventBus() {
    super(ThreadEnforcer.ANY);
}
 
Example #16
Source File: TodoListManagerTest.java    From FluxyAndroidTodo with MIT License 4 votes vote down vote up
@Before
public void setup() {
    actionBus = new ActionBus();
    dataBus = new DataBus(ThreadEnforcer.ANY);
    list = new TodoListManager(actionBus, dataBus);
}
 
Example #17
Source File: TodosActivityStoreTest.java    From FluxyAndroidTodo with MIT License 4 votes vote down vote up
@Before
public void setup() {
    actionBus = new ActionBus();
    dataBus = new DataBus(ThreadEnforcer.ANY);
    store = new TodosActivityStore(actionBus, dataBus);
}
 
Example #18
Source File: ActionBus.java    From FluxyAndroidTodo with MIT License 4 votes vote down vote up
@Inject
public ActionBus() {
    super(ThreadEnforcer.ANY);
}
 
Example #19
Source File: DataBus.java    From FluxyAndroidTodo with MIT License 4 votes vote down vote up
public DataBus(ThreadEnforcer thread) {
    super(thread);
}
 
Example #20
Source File: DataBus.java    From FluxyAndroidTodo with MIT License 4 votes vote down vote up
public DataBus() {
    super(ThreadEnforcer.MAIN);
}
 
Example #21
Source File: BusProvider.java    From quill with MIT License 4 votes vote down vote up
@RestrictTo(RestrictTo.Scope.TESTS)
public static void setupForTesting() {
    sBus = new Bus(ThreadEnforcer.ANY);
}