当前位置: 首页>>代码示例>>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;未经允许,请勿转载。