當前位置: 首頁>>代碼示例>>Java>>正文


Java Bus類代碼示例

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

}
 
開發者ID:jianliaoim,項目名稱:talk-android,代碼行數:20,代碼來源:Team.java

示例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<>();
}
 
開發者ID:0nko,項目名稱:Architecture-Demo,代碼行數:17,代碼來源:EditPostComponentViewModel.java

示例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);
}
 
開發者ID:0nko,項目名稱:Architecture-Demo,代碼行數:18,代碼來源:PostComponentViewModel.java

示例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;
}
 
開發者ID:0nko,項目名稱:Architecture-Demo,代碼行數:19,代碼來源:Post.java

示例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));
}
 
開發者ID:0nko,項目名稱:Architecture-Demo,代碼行數:22,代碼來源:Repository.java

示例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;
}
 
開發者ID:iem-devs,項目名稱:apna-library,代碼行數:33,代碼來源:ApiClient.java

示例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;
}
 
開發者ID:KlubJagiellonski,項目名稱:pola-android,代碼行數:27,代碼來源:MainPresenter.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:PerfTestOtto.java

示例9: DataManager

import com.squareup.otto.Bus; //導入依賴的package包/類
public DataManager(DatabaseHelper databaseHelper,
                   Bus eventBus,
                   Scheduler subscribeScheduler) {
    mDatabaseHelper = databaseHelper;
    mEventBus = eventBus;
    mSubscribeScheduler = subscribeScheduler;
}
 
開發者ID:sathishmscict,項目名稱:Pickr,代碼行數:8,代碼來源:DataManager.java

示例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();
        }
    }
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:14,代碼來源:NetworkService.java

示例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());
}
 
開發者ID:jianliaoim,項目名稱:talk-android,代碼行數:11,代碼來源:User.java

示例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");
}
 
開發者ID:gnosygnu,項目名稱:xowa_android,代碼行數:29,代碼來源:WikipediaApp.java

示例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();
}
 
開發者ID:Guardiola31337,項目名稱:CatanArchitecture,代碼行數:10,代碼來源:BaseApp.java

示例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;
}
 
開發者ID:trigor74,項目名稱:travelers-diary,代碼行數:13,代碼來源:BusProvider.java

示例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);
}
 
開發者ID:0nko,項目名稱:Architecture-Demo,代碼行數:14,代碼來源:PostListComponentViewModel.java


注:本文中的com.squareup.otto.Bus類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。