本文整理匯總了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);
}