com.squareup.otto.Bus.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中com.squareup.otto.Bus.<init>()方法的一些代码示例,展示了Bus.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bus.<init>()方法的具体详情如下:
包路径:com.squareup.otto.Bus
类名称:Bus
方法名:<init>

Bus.<init>介绍

[英]Creates a new Bus named "default" that enforces actions on the main thread.
[中]创建名为“default”的新总线,该总线在主线程上强制执行操作。

代码示例

代码示例来源:origin: androidannotations/androidannotations

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Bus bus = new Bus();
  bus.register(this);
}

代码示例来源:origin: greenrobot/EventBus

public PerfTestOtto(Context context, TestParams params) {
  super(context, params);
  eventBus = new Bus(ThreadEnforcer.ANY);
  subscribers = new ArrayList<Object>();
  eventCount = params.getEventCount();
  expectedEventCount = eventCount * params.getSubscriberCount();
  subscriberClass = Subscriber.class;
}

代码示例来源:origin: ribot/ribot-app-android

@Provides
@Singleton
Bus provideEventBus() {
  return new Bus();
}

代码示例来源:origin: ribot/ribot-app-android

@Provides
@Singleton
Bus provideEventBus() {
  return new Bus();
}

代码示例来源:origin: vogellacompany/codeexamples-android

@Override
public void onCreate() {
  super.onCreate();
  ottoBus = new Bus();
}

代码示例来源:origin: NimbleDroid/FriendlyDemo

@Provides
@Singleton
Bus provideEventBus() {
  return new Bus();
}

代码示例来源:origin: rakuishi/todo-android

@Provides @Singleton
  public Bus provideBus() {
    return new Bus();
  }
}

代码示例来源:origin: f2prateek/device-frame-generator

@Provides @Singleton Bus provideBus() {
 return new Bus();
}

代码示例来源:origin: stackoverflow.com

Bus bus = new Bus();
bus.post(new SomeCoolEvent(yourWisdomStringFromThisClass));

代码示例来源:origin: vogellacompany/codeexamples-android

@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);
    }
  }
}

代码示例来源:origin: stackoverflow.com

Bus bus = new Bus();
bus.register(context);
bus.post(new MyObject(xxx));

代码示例来源:origin: ChrisZou/android-unit-testing-tutorial

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.checkout_activity);
  String paymentId = "some paymentId"; //这个是从外面传进来的
  mCheckoutModel = new CheckoutModel(new PaymentApi(), new Bus()); //假设这里是使用Dagger2注入进来的,具体这种怎么实现,请参考后续文章。
  mCheckoutModel.loadCheckoutData(paymentId);
}

代码示例来源:origin: EasyDSS/EasyCamera

@Override
public void onCreate() {
  super.onCreate();
  mApplication = this;
  if (Util.getSupportResolution(this).size() == 0) {
    StringBuilder stringBuilder = new StringBuilder();
    Camera camera = Camera.open();
    List<Camera.Size> supportedPreviewSizes = camera.getParameters().getSupportedPreviewSizes();
    for (Camera.Size str : supportedPreviewSizes) {
      stringBuilder.append(str.width + "x" + str.height).append(";");
    }
    Util.saveSupportResolution(this, stringBuilder.toString());
    camera.release();
  }
  initSystemConfig();
  sMainBus = new Bus(ThreadEnforcer.ANY);
  aio = new AudioIO(this, sMainBus, 8000, false);
}

代码示例来源:origin: stackoverflow.com

Bus bus = new Bus();
 bus.post(new JobFinishedEvent(42));

代码示例来源:origin: pwittchen/NetworkEvents

@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<>();
}

代码示例来源:origin: pwittchen/NetworkEvents

@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<>();
}

代码示例来源:origin: pwittchen/NetworkEvents

@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);
}

代码示例来源:origin: pwittchen/NetworkEvents

@Test(expected = IllegalArgumentException.class) public void testContextShouldNotBeNull() {
 // given
 Context nullContext = null;
 BusWrapper busWrapper = new OttoBusWrapper(new Bus());
 // when
 new NetworkEvents(nullContext, busWrapper);
 // then throw an exception
}

代码示例来源:origin: stackoverflow.com

class FragmentA {
  Bus bus;

  onCreate(){
   bus = new Bus();
  }

  @Subscribe public void receiveMessage(String message) {
    // TODO: Parse your message
  }

  onResume(){
   bus.register(this);
  }

  onPause(){
   bus.unregister(this);
  }
}

class FragmentB {

  onCreate(){
   bus.post("You have a message");
  }
}

代码示例来源:origin: pwittchen/NetworkEvents

@Override protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 connectivityStatus = (TextView) findViewById(R.id.connectivity_status);
 mobileNetworkType = (TextView) findViewById(R.id.mobile_network_type);
 accessPoints = (ListView) findViewById(R.id.access_points);
 busWrapper = getOttoBusWrapper(new Bus());
 networkEvents = new NetworkEvents(getApplicationContext(), busWrapper).enableInternetCheck()
   .enableWifiScan();
}

相关文章