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

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

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

Bus.post介绍

[英]Posts an event to all registered handlers. This method will return successfully after the event has been posted to all handlers, and regardless of any exceptions thrown by handlers.

If no handlers have been subscribed for event's class, and event is not already a DeadEvent, it will be wrapped in a DeadEvent and reposted.
[中]将事件发布到所有已注册的处理程序。此方法将在事件发布到所有处理程序后成功返回,而不管处理程序引发任何异常。
若并没有为事件的类订阅任何处理程序,并且事件还不是DeadEvent,那个么它将被包装在DeadEvent中并重新发布。

代码示例

代码示例来源:origin: commonsguy/cw-omnibus

@Override
protected void doWakefulWork(Intent intent) {
 bus.post(new RandomEvent(rng.nextInt()));
}

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

public void runTest() {
  TestEvent event = new TestEvent();
  long timeStart = System.nanoTime();
  for (int i = 0; i < super.eventCount; i++) {
    super.eventBus.post(event);
    if (canceled) {
      break;
    }
  }
  long timeAfterPosting = System.nanoTime();
  waitForReceivedEventCount(super.expectedEventCount);
  primaryResultMicros = (timeAfterPosting - timeStart) / 1000;
  primaryResultCount = super.expectedEventCount;
}

代码示例来源:origin: square/otto

@Override public void onClick(View v) {
  lastLatitude += (RANDOM.nextFloat() * OFFSET * 2) - OFFSET;
  lastLongitude += (RANDOM.nextFloat() * OFFSET * 2) - OFFSET;
  BusProvider.getInstance().post(produceLocationEvent());
 }
});

代码示例来源:origin: square/otto

@Override public void onClick(View v) {
  // Tell everyone to clear their location history.
  BusProvider.getInstance().post(new LocationClearEvent());
  // Post new location event for the default location.
  lastLatitude = DEFAULT_LAT;
  lastLongitude = DEFAULT_LON;
  BusProvider.getInstance().post(produceLocationEvent());
 }
});

代码示例来源:origin: square/otto

@Override protected void onPostExecute(Drawable drawable) {
  if (!isCancelled() && drawable != null) {
   BusProvider.getInstance().post(new ImageAvailableEvent(drawable));
  }
 }
}

代码示例来源:origin: square/otto

post(new DeadEvent(this, event));

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

@Override
  public void run() {
    mBus.post(event);
  }
});

代码示例来源:origin: jberkel/sms-backup-plus

public static void post(Object event) {
  bus.post(event);
}

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

@Override
  public void run() {
    eventBus.post(new BusEvent.AuthenticationError());
  }
});

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

@Override
  public void run() {
    mBus.post(event);
  }
});

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

@Override
  public void onFailure(int code, String msg) {
    mBus.post(new DataLoadedEvent(code, msg));
  }
});

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

@Override
  protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    String string = extras.getString("url");
    List<RssItem> list = RssFeedProvider.parse(string);
    RssApplication.list = list;
    RssApplication.bus.post(RSS_UPDATE);
  }
}

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

@Override
  public void onClick(View v) {
    ((MyApplication) getActivity().getApplicationContext()).getOttoBus().post(v);
  }
});

代码示例来源:origin: amahi/android

@Override
  public void onFailure(Call<ServerRoute> call, Throwable t) {
    BusProvider.getBus().post(new ServerRouteLoadFailedEvent(t.getMessage()));
  }
}

代码示例来源:origin: amahi/android

@Override
public void onResponse(Call<ServerFileMetadata> call, Response<ServerFileMetadata> response) {
  View fileView = fileViewReference.get();
  if (fileView == null) {
    return;
  }
  if (!file.equals(fileView.getTag(ServerFilesMetadataAdapter.Tags.FILE))) {
    return;
  }
  BusEvent busEvent = new FileMetadataRetrievedEvent(file, response.body(), fileView, viewHolder);
  BusProvider.getBus().post(busEvent);
}

代码示例来源:origin: amahi/android

@Override
  public void onClick(View view) {
    BusProvider.getBus().post(new AudioControlNextEvent());
  }
}

代码示例来源:origin: amahi/android

@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
  if (playbackState == Player.STATE_ENDED) {
    BusProvider.getBus().post(new AudioCompletedEvent());
  } else if (playbackState == Player.STATE_READY && isPreparing) {
    isPreparing = false;
    BusProvider.getBus().post(new AudioPreparedEvent());
  }
}

代码示例来源:origin: amahi/android

@Override
  public void onFailure(Call<Void> call, Throwable t) {
    BusProvider.getBus().post(new ServerFileDeleteEvent(false));
  }
}

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

@OnClick(R.id.iv_device_default) public void updateDefaultDevice() {
 if (isDefault()) {
  return;
 }
 deviceProvider.saveDefaultDevice(device);
 bus.post(new Events.DefaultDeviceUpdated(device));
}

代码示例来源:origin: amahi/android

private void stopDownloading(long downloadId) {
  DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
  if (dm != null) {
    dm.remove(downloadId);
    BusProvider.getBus().post(new OfflineCanceledEvent(downloadId));
  }
}

相关文章