本文整理匯總了Java中com.squareup.otto.Bus類的典型用法代碼示例。如果您正苦於以下問題:Java Bus類的具體用法?Java Bus怎麽用?Java Bus使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Bus類屬於com.squareup.otto包,在下文中一共展示了Bus類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: update
import com.squareup.otto.Bus; //導入依賴的package包/類
public static void update(final Team team, final Bus bus) {
Observable.create(new Observable.OnSubscribe<Object>() {
@Override
public void call(Subscriber<? super Object> subscriber) {
if (BizLogic.isCurrentTeam(team.get_id())) {
MainApp.PREF_UTIL.putObject(Constant.TEAM, team);
subscriber.onNext(null);
}
}
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<Object>() {
@Override
public void call(Object o) {
bus.post(new UpdateTeamEvent());
}
});
}
示例2: EditPostComponentViewModel
import com.squareup.otto.Bus; //導入依賴的package包/類
@Inject
public EditPostComponentViewModel(Bus bus,
INavigator navigator,
IRepository repository,
ILocalization localization) {
super(bus);
this.navigator = navigator;
this.repository = repository;
this.localization = localization;
this.saveCommand = new Command(this::savePost);
this.title = new ObservableField<>();
this.summary = new ObservableField<>();
}
示例3: PostComponentViewModel
import com.squareup.otto.Bus; //導入依賴的package包/類
public PostComponentViewModel(Bus bus,
Post post,
INavigator navigator,
ILocalization localization,
PostListComponentViewModel postListViewModel) {
super(bus);
this.post = post;
this.navigator = navigator;
this.localization = localization;
this.postListViewModel = postListViewModel;
this.openCommand = new Command(this::openUrl);
this.editCommand = new Command(this::editPost);
this.deleteCommand = new Command(this::deletePost);
}
示例4: Post
import com.squareup.otto.Bus; //導入依賴的package包/類
public Post(Bus bus,
int id,
String tile,
String summary,
String url,
String likes,
String comments,
@Nullable String imageUrl) {
this.bus = bus;
this.id = id;
this.title = tile;
this.summary = summary;
this.url = url;
this.likes = likes;
this.comments = comments;
this.imageUrl = imageUrl;
}
示例5: Repository
import com.squareup.otto.Bus; //導入依賴的package包/類
public Repository(Bus bus) {
posts = new HashMap<>();
int id = 0;
// Fake posts
posts.put(id, new Post(bus, id++, "Crush your enemies", "I'll give 1 million dollars CASH " +
"to the first man to fill this urn with my opponent's ashes-JK!",
"https://twitter.com/pete_schultz/status/763605581936599040",
"100", "5", "https://pbs.twimg.com/media/CpjfOAtWYAAQelu.jpg"));
posts.put(id, new Post(bus, id++, "Data Binding Rulez", "Having the views and business " +
"logic (BL) mixed up in 5000 line-long activities is nice and all but it doesn’t " +
"have to be that way. One of the key advantages of using data binding is a chance " +
"to nicely separate the presentation layer from the BL.",
"https://hogwartsp2.wordpress.com/2016/07/28/the-magic-of-android-data-binding-library/",
"5", "4", "https://i2.wp.com/cases.azoft.com/images/2015/12/pattern-mvvm-scheme.png"));
posts.put(id, new Post(bus, id++, "Saturday renamed Caturday", "Lolcats take over the planet.",
"https://hogwartsp2.wordpress.com/2016/08/09/hackday-fluxc-rest-improvements/",
"1", "14", null));
}
示例6: 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;
}
示例7: create
import com.squareup.otto.Bus; //導入依賴的package包/類
public static MainPresenter create(Context applicationContext, @NonNull final MainViewBinder viewBinder,
@NonNull final ProductList productList,
@NonNull final ProductsAdapter productsAdapter,
@NonNull SessionId sessionId,
@NonNull final Bus eventBus) {
productList.setOnProductListChanged(new OnProductListChanged() {
@Override
public void onChanged() {
productsAdapter.notifyDataSetChanged();
}
});
viewBinder.setAdapter(productsAdapter);
final Api api = PolaApplication.retrofit.create(Api.class);
final EventLogger logger = new EventLogger(applicationContext);
final MainPresenter mainPresenter = new MainPresenter(viewBinder, productList, api, logger, sessionId, eventBus);
productsAdapter.setOnProductClickListener(new ProductsAdapter.ProductClickListener() {
@Override
public void itemClicked(SearchResult searchResult) {
mainPresenter.onItemClicked(searchResult);
}
});
return mainPresenter;
}
示例8: PerfTestOtto
import com.squareup.otto.Bus; //導入依賴的package包/類
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;
}
示例9: DataManager
import com.squareup.otto.Bus; //導入依賴的package包/類
public DataManager(DatabaseHelper databaseHelper,
Bus eventBus,
Scheduler subscribeScheduler) {
mDatabaseHelper = databaseHelper;
mEventBus = eventBus;
mSubscribeScheduler = subscribeScheduler;
}
示例10: 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();
}
}
}
示例11: 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());
}
示例12: onCreate
import com.squareup.otto.Bus; //導入依賴的package包/類
@Override
public void onCreate() {
super.onCreate();
Gfo_log_.Instance.Info("app.create.bgn");
initExceptionHandling();
bus = new Bus();
final Resources resources = getResources();
ViewAnimations.init(resources);
screenDensity = resources.getDisplayMetrics().density;
currentTheme = unmarshalCurrentTheme();
appLanguageState = new AppLanguageState(this);
funnelManager = new FunnelManager(this);
sessionFunnel = new SessionFunnel(this);
editTokenStorage = new EditTokenStorage(this);
cookieManager = new SharedPreferenceCookieManager();
dbOpenHelper = new DBOpenHelper(this);
enableWebViewDebugging();
Api.setConnectionFactory(new OkHttpConnectionFactory(this));
zeroHandler = new WikipediaZeroHandler(this);
pageCache = new PageCache(this);
Gfo_log_.Instance.Info("app.create.end");
}
示例13: onCreate
import com.squareup.otto.Bus; //導入依賴的package包/類
@Override public void onCreate() {
super.onCreate();
eventsPort = new OttoEventsAdapter(new Bus());
StoragePort storagePort = new SDCardStorageAdapter(eventsPort);
FoldersModule notesModule = new FoldersModule(storagePort, eventsPort);
notesModule.run();
}
示例14: bus
import com.squareup.otto.Bus; //導入依賴的package包/類
public static Bus bus() {
Bus localInstance = instance;
if (localInstance == null) {
synchronized (AndroidBus.class) {
localInstance = instance;
if (localInstance == null) {
instance = localInstance = new AndroidBus(ThreadEnforcer.ANY);
}
}
}
return localInstance;
}
示例15: PostListComponentViewModel
import com.squareup.otto.Bus; //導入依賴的package包/類
@Inject
public PostListComponentViewModel(Bus bus, IRepository repository, INavigator navigator, ILocalization localization) {
super(bus);
this.repository = repository;
this.navigator = navigator;
this.localization = localization;
this.posts = new ObservableArrayList<>();
this.isBusy = new ObservableBoolean();
this.loadCommand = new Command(this::loadPosts);
}