本文整理汇总了Java中com.squareup.otto.Bus.post方法的典型用法代码示例。如果您正苦于以下问题:Java Bus.post方法的具体用法?Java Bus.post怎么用?Java Bus.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.squareup.otto.Bus
的用法示例。
在下文中一共展示了Bus.post方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOttoCallback
import com.squareup.otto.Bus; //导入方法依赖的package包/类
/**
* API to get the callback inorder to start the request
* Usage :
* Callback<ModelType> callback = ApiClient.getOttoCallback(Config.SOME_TAG)
* ApiClient.getApiService(bus).getApi().getSomeDataApi(callback)
* @param accessType String to define the return type. Should be defined in Config file. Should
* be different in order to identify the return value
* @param <T> generic type
* @return Retrofit Callback
*/
public static <T> Callback<T> getOttoCallback(final String accessType) {
final Bus mBus = apiBus;
Callback<T> callback = new Callback<T>() {
@Override
public void success(T t, Response response) {
Log.i(Config.TAG, "" + response.getStatus());
if(mBus != null) {
mBus.post(t);
mBus.post(new RetrofitSucessEvent(response, accessType));
}
}
@Override
public void failure(RetrofitError error) {
Log.e(Config.TAG,error.toString());
if(mBus != null) {
mBus.post(new RetrofitErrorEvent(error, accessType));
}
}
};
return callback;
}
示例2: flushApiEventQueue
import com.squareup.otto.Bus; //导入方法依赖的package包/类
private void flushApiEventQueue(boolean loadCachedData) {
Bus bus = getBus();
boolean isQueueEmpty;
while (! mApiEventQueue.isEmpty()) {
ApiCallEvent event = mApiEventQueue.remove();
isQueueEmpty = mApiEventQueue.isEmpty();
if (loadCachedData) event.loadCachedData();
bus.post(event);
if (isQueueEmpty) { // don't retry, gets into infinite loop
mApiEventQueue.clear();
}
}
}
示例3: update
import com.squareup.otto.Bus; //导入方法依赖的package包/类
public void update(Bus bus) {
if (preference == null) {
User user = (User) MainApp.PREF_UTIL.getObject(Constant.USER, User.class);
if (user != null) {
setPreference(user.getPreference());
}
}
MainApp.PREF_UTIL.putObject(Constant.USER, this);
bus.post(new UpdateUserEvent());
}
示例4: onListItemClick
import com.squareup.otto.Bus; //导入方法依赖的package包/类
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Bus bus = FootballBus.getInstance();
bus.post(new OnFootballTeamCLickedEvent(teams.get(position)));
}
示例5: postEvent
import com.squareup.otto.Bus; //导入方法依赖的package包/类
@Override
public void postEvent(Bus bus) {
bus.post(this);
}