Java Code Examples for com.squareup.otto.ThreadEnforcer#ANY

The following examples show how to use com.squareup.otto.ThreadEnforcer#ANY . 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: 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 3
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 4
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 5
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);
}
 
Example 6
Source File: ActionBus.java    From FluxyAndroidTodo with MIT License 4 votes vote down vote up
@Inject
public ActionBus() {
    super(ThreadEnforcer.ANY);
}
 
Example 7
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 8
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 9
Source File: EventBus.java    From GameOfLife with MIT License 4 votes vote down vote up
private EventBus() {
    super(ThreadEnforcer.ANY);
}
 
Example 10
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 11
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 12
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 13
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)); }