io.reactivex.disposables.CompositeDisposable Java Examples
The following examples show how to use
io.reactivex.disposables.CompositeDisposable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SettingsPresenterTest.java From adamant-android with GNU General Public License v3.0 | 6 votes |
@Before public void setUp() { Context systemContext = RuntimeEnvironment.systemContext; TestAppComponent component = DaggerTestAppComponent .builder() .context(systemContext) .build(); component.inject(this); view = mock(SettingsView.class); disposable = new CompositeDisposable(); presenter = new SettingsPresenter( router, accountInteractor, logoutInteractor, api, securityInteractor, switchPushNotificationServiceInteractor, Schedulers.trampoline() ); }
Example #2
Source File: OrgUnitHolder.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
OrgUnitHolder(FragmentManager fm, ViewDataBinding binding, FlowableProcessor<RowAction> processor) { super(binding); compositeDisposable = new CompositeDisposable(); this.editText = binding.getRoot().findViewById(R.id.input_editText); this.inputLayout = binding.getRoot().findViewById(R.id.input_layout); this.description = binding.getRoot().findViewById(R.id.descriptionLabel); this.editText.setOnClickListener(view -> { editText.setEnabled(false); orgUnitDialog = new OrgUnitDialog() .setTitle(model.label()) .setMultiSelection(false) .setPossitiveListener(data -> { processor.onNext(RowAction.create(model.uid(), orgUnitDialog.getSelectedOrgUnit(), model.dataElement(), model.categoryOptionCombo(),model.catCombo(), model.row(), model.column())); this.editText.setText(orgUnitDialog.getSelectedOrgUnitName()); orgUnitDialog.dismiss(); editText.setEnabled(true); }) .setNegativeListener(data -> { orgUnitDialog.dismiss(); editText.setEnabled(true); }); if (!orgUnitDialog.isAdded()) orgUnitDialog.show(fm, model.label()); }); }
Example #3
Source File: DateTimeHolder.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
DateTimeHolder(ViewDataBinding binding, FlowableProcessor<RowAction> processor) { super(binding); this.disposable = new CompositeDisposable(); this.processor = processor; if (binding instanceof TableTimeTextBinding) { ((TableTimeTextBinding) binding).timeView.setDateListener(this); } if (binding instanceof TableDateTextBinding) { ((TableDateTextBinding) binding).dateView.setDateListener(this); } if (binding instanceof TableDateTimeTextBinding) { ((TableDateTimeTextBinding) binding).dateTimeView.setDateListener(this); } }
Example #4
Source File: BusUtil.java From RxPay with Apache License 2.0 | 6 votes |
/** * 保存订阅后的disposable * @param o * @param disposable */ public void addSubscription(Object o, Disposable disposable) { if (mSubscriptionMap == null) { mSubscriptionMap = new HashMap<>(); } String key = o.getClass().getName(); CompositeDisposable compositeDisposable = mSubscriptionMap.get(key); if (compositeDisposable != null) { compositeDisposable.add(disposable); } else { //一次性容器,可以持有多个并提供 添加和移除。 CompositeDisposable disposables = new CompositeDisposable(); disposables.add(disposable); mSubscriptionMap.put(key, disposables); } }
Example #5
Source File: StockViewModel.java From Building-Professional-Android-Applications with MIT License | 6 votes |
@Override public void bind(ViewActivity<PortfolioListData> activity) { super.bind(activity); disposable = new CompositeDisposable(); Disposable subscribe = Observable.combineLatest( portfolioRepository.getPortfolioItems() .toList() .toObservable(), purchasesService.monitorPurchases(getActivity()), (items, hasPurchases) -> data.withItems(items).withSummaryActive(hasPurchases) ) .subscribe(this::update, RxError::handler); disposable.addAll( subscribe ); }
Example #6
Source File: StockViewModel.java From Building-Professional-Android-Applications with MIT License | 6 votes |
@Override public void bind(ViewActivity<PortfolioListData> activity) { super.bind(activity); disposable = new CompositeDisposable(); Disposable subscribe = Observable.combineLatest( portfolioRepository.getPortfolioItems() .toList() .toObservable(), purchasesService.monitorPurchases(getActivity()), (items, hasPurchases) -> data.withItems(items).withSummaryActive(hasPurchases) ) .subscribe(this::update, RxError::handler); disposable.addAll( subscribe ); }
Example #7
Source File: RxBus.java From RxBus with Apache License 2.0 | 6 votes |
public <T> void registerSubscriber(@NonNull Object observer, @NonNull CustomSubscriber<T> subscriber) { ObjectHelper.requireNonNull(observer, "Observer to register must not be null."); ObjectHelper.requireNonNull(subscriber, "Subscriber to register must not be null."); SUBSCRIBERS.putIfAbsent(observer.getClass(), new CopyOnWriteArraySet<CustomSubscriber<?>>()); Set<CustomSubscriber<?>> subscribers = SUBSCRIBERS.get(observer.getClass()); if (subscribers.contains(subscriber)) throw new IllegalArgumentException("Subscriber has already been registered."); else subscribers.add(subscriber); Observable<T> observable = bus.ofType(subscriber.getEventClass()) .observeOn(subscriber.getScheduler() == null ? AndroidSchedulers.mainThread() : subscriber.getScheduler()); Class<?> observerClass = observer.getClass(); OBSERVERS.putIfAbsent(observerClass, new CompositeDisposable()); CompositeDisposable composite = OBSERVERS.get(observerClass); composite.add(((subscriber.getFilter() == null) ? observable : observable.filter(subscriber.getFilter())) .subscribe(subscriber)); }
Example #8
Source File: ObserverUtil.java From Learning-Resources with MIT License | 6 votes |
/** * @return SingleObserver with which observable will subscribe */ public static <T> SingleObserver<T> getSingleObserver(final CompositeDisposable compositeDisposable, final WebserviceBuilder.ApiNames apiNames, final SingleCallback tSingleCallback) { return new SingleObserver<T>() { @Override public void onSubscribe(Disposable d) { if (compositeDisposable != null) compositeDisposable.add(d); } @Override public void onSuccess(@NonNull T t) { if (tSingleCallback != null) tSingleCallback.onSingleSuccess(t, apiNames); } @Override public void onError(Throwable e) { if (tSingleCallback != null) tSingleCallback.onFailure(e, apiNames); } }; }
Example #9
Source File: CheckSourceService.java From a with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); SharedPreferences preference = MApplication.getConfigPreferences(); checkSourceListener = new CheckSourceListener() { @Override public void nextCheck() { CheckSourceService.this.nextCheck(); } @Override public void compositeDisposableAdd(Disposable disposable) { compositeDisposable.add(disposable); } @Override public int getCheckIndex() { return checkIndex; } }; threadsNum = preference.getInt(this.getString(R.string.pk_threads_num), 6); executorService = Executors.newFixedThreadPool(threadsNum); scheduler = Schedulers.from(executorService); compositeDisposable = new CompositeDisposable(); updateNotification(0, "正在加载"); }
Example #10
Source File: UpdateBookListService.java From a with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); SharedPreferences preference = MApplication.getConfigPreferences(); updateBookListListener = new UpdateBookListListener() { @Override public void nextCheck() { UpdateBookListService.this.nextCheck(); } @Override public void compositeDisposableAdd(Disposable disposable) { compositeDisposable.add(disposable); } @Override public int getCheckIndex() { return checkIndex; } }; threadsNum = preference.getInt(this.getString(R.string.pk_threads_num), 6); executorService = Executors.newFixedThreadPool(threadsNum); scheduler = Schedulers.from(executorService); compositeDisposable = new CompositeDisposable(); updateNotification(0, "正在加载"); }
Example #11
Source File: ArtistArtDownloadService.java From Rey-MusicPlayer with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); mCompositeDisposable = new CompositeDisposable(); mApiInterface = ApiClient.getClient().create(LastFmInterface.class); mApp = (Common) getApplicationContext(); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationBuilder = new Notification.Builder(this); mNotificationBuilder.setContentTitle(getResources().getString(R.string.downloading_artist_arts)) .setContentText(getResources().getString(R.string.downloading_art_for)) .setSmallIcon(R.mipmap.ic_music_file); startForeground(mNotificationId, mNotificationBuilder.build()); mCompositeDisposable.add(Observable.fromCallable(() -> downloadAndUpdateArts()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribeWith(downloadAndUpdateObserver)); }
Example #12
Source File: PageLoader.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
/*****************************init params*******************************/ PageLoader(PageView pageView, BookShelfBean book, Callback callback) { mPageView = pageView; this.book = book; this.callback = callback; for (int i = 0; i < 3; i++) { chapterContainers.add(new ChapterContainer()); } mContext = pageView.getContext(); mCurChapterPos = book.getDurChapter(); mCurPagePos = book.getDurChapterPage(); compositeDisposable = new CompositeDisposable(); oneSpPx = ScreenUtils.spToPx(1); // 初始化数据 initData(); // 初始化画笔 initPaint(); }
Example #13
Source File: RxJavaOperatorActivity.java From My-MVP with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_rx_java_operator); ButterKnife.bind(this); mCompositeDisposable = new CompositeDisposable(); }
Example #14
Source File: MainActivity.java From Luban with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDisposable = new CompositeDisposable(); RecyclerView mRecyclerView = findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); mRecyclerView.setAdapter(mAdapter); initPermission(); }
Example #15
Source File: ScopeViewModel.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
private void addDisposable(Disposable disposable) { CompositeDisposable disposables = mDisposables; if (disposables == null) { disposables = mDisposables = new CompositeDisposable(); } disposables.add(disposable); }
Example #16
Source File: SongsFragment.java From Rey-MusicPlayer with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mView = inflater.inflate(R.layout.fragment_album_layout, container, false); mContext = getContext(); setHasOptionsMenu(true); mCompositeDisposable = new CompositeDisposable(); mApp = (Common) mContext.getApplicationContext(); mSongList = new ArrayList<>(); mFastScroller = mView.findViewById(R.id.fast_scroller); mRecyclerView = mView.findViewById(R.id.recyclerView); mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext)); mFastScroller.setRecyclerView(mRecyclerView); mAdapter = new SongsAdapter(getActivity(), this); mRecyclerView.setAdapter(mAdapter); mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST, 85, 20)); mRecyclerView.addOnScrollListener(new HidingScrollListener() { @Override public void onHide() { mOnScrolledListener.onScrolledUp(); } @Override public void onShow() { mOnScrolledListener.onScrolledDown(); } }); return mView; }
Example #17
Source File: LikePhotoPresenter.java From Mysplash with GNU Lesser General Public License v3.0 | 5 votes |
private LikePhotoPresenter() { photoList = new ArrayList<>(); photoService = new PhotoService( ComponentCollection.getInstance().getHttpClient(), ComponentCollection.getInstance().getGsonConverterFactory(), ComponentCollection.getInstance().getRxJava2CallAdapterFactory(), new CompositeDisposable() ); lock = new ReentrantReadWriteLock(); }
Example #18
Source File: NetworkServiceModule.java From Mysplash with GNU Lesser General Public License v3.0 | 5 votes |
@Provides public FeedService getFeedService(@ApplicationInstance OkHttpClient client, @ApplicationInstance GsonConverterFactory gsonConverterFactory, @ApplicationInstance RxJava2CallAdapterFactory rxJava2CallAdapterFactory, CompositeDisposable disposable) { return new FeedService(client, gsonConverterFactory, rxJava2CallAdapterFactory, disposable); }
Example #19
Source File: BaseScope.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
private void addDisposable(Disposable disposable) { CompositeDisposable disposables = mDisposables; if (disposables == null) { disposables = mDisposables = new CompositeDisposable(); } disposables.add(disposable); }
Example #20
Source File: NfcDataWriteActivity.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onResume() { super.onResume(); disposable = new CompositeDisposable(); if (nfcManager.verifyNFC()) init(); else { Intent setnfc = new Intent(Settings.ACTION_SETTINGS); startActivity(setnfc); } }
Example #21
Source File: SingleActivity.java From Learning-Resources with MIT License | 5 votes |
private void callAPI() { compositeDisposable = new CompositeDisposable(); ObserverUtil .subscribeToSingle(ApiClient.getClient().create(WebserviceBuilder.class).getSingleObject() , compositeDisposable, WebserviceBuilder.ApiNames.single, this); }
Example #22
Source File: BaseDialog.java From FFmpegCommand with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); disposables = new CompositeDisposable(); isPrepared = true; init(); lazyLoad(); }
Example #23
Source File: DataSetDetailPresenter.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
public DataSetDetailPresenter(DataSetDetailView view, DataSetDetailRepository dataSetDetailRepository, SchedulerProvider schedulerProvider, FilterManager filterManager) { this.view = view; this.dataSetDetailRepository = dataSetDetailRepository; this.schedulerProvider = schedulerProvider; this.filterManager = filterManager; disposable = new CompositeDisposable(); }
Example #24
Source File: LoginPresenterTest.java From android-mvp-interactor-architecture with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { CompositeDisposable compositeDisposable = new CompositeDisposable(); mTestScheduler = new TestScheduler(); TestSchedulerProvider testSchedulerProvider = new TestSchedulerProvider(mTestScheduler); mLoginPresenter = new LoginPresenter<>( mMockLoginMvpInteractor, testSchedulerProvider, compositeDisposable); mLoginPresenter.onAttach(mMockLoginMvpView); }
Example #25
Source File: RetrofitFragment.java From RxJava-Android-Samples with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String githubToken = getResources().getString(R.string.github_oauth_token); _githubService = GithubService.createGithubService(githubToken); _disposables = new CompositeDisposable(); }
Example #26
Source File: NetworkServiceModule.java From Mysplash with GNU Lesser General Public License v3.0 | 5 votes |
@Provides public StatusService getStatusService(@ApplicationInstance OkHttpClient client, @ApplicationInstance GsonConverterFactory gsonConverterFactory, @ApplicationInstance RxJava2CallAdapterFactory rxJava2CallAdapterFactory, CompositeDisposable disposable) { return new StatusService(client, gsonConverterFactory, rxJava2CallAdapterFactory, disposable); }
Example #27
Source File: StoryListPresenter.java From News with Apache License 2.0 | 5 votes |
StoryListPresenter(@NonNull StoriesDataRepository repository, @NonNull StoryListContract.View view) { this.mRepository = repository; this.mNewsListView = view; this.mSchedulerProvider = SchedulerProvider.getInstance(); this.mDisposables = new CompositeDisposable(); this.mNewsListView.setPresenter(this); }
Example #28
Source File: PeriodicEmittingDataSourceFunction.java From FlinkExperiments with MIT License | 5 votes |
@Override public void run(SourceContext<TEventType> sourceContext) throws Exception { disposables = new CompositeDisposable(); Observable // We zip two Streams: The Iterable and an Interval emitting data stream: .zip( Observable.fromIterable(iterable()), Observable.interval(interval().toMillis(), TimeUnit.MILLISECONDS), new BiFunction<TEventType, Long, TEventType>() { @Override public TEventType apply(@NonNull TEventType obs, @NonNull Long timer) throws Exception { return obs; } } ) // When the Subscription happens, add it to the list of Disposables: .doOnSubscribe(new Consumer<Disposable>() { @Override public void accept(Disposable disposable) throws Exception { disposables.add(disposable); } }) // We want this to be synchronous on the current thread, so do all this in a blocking subscribe: .blockingSubscribe(new Consumer<TEventType>() { @Override public void accept(TEventType event) throws Exception { sourceContext.collect(event); } }); }
Example #29
Source File: FavoritesPresenter.java From WanAndroid with Apache License 2.0 | 5 votes |
public FavoritesPresenter(FavoritesContract.View view,FavoriteArticlesDataRepository repository) { this.repository = repository; this.view = view; compositeDisposable = new CompositeDisposable(); this.view.setPresenter(this); }
Example #30
Source File: ThreadsListFragmentPresenter.java From demo-firebase-android with The Unlicense | 5 votes |
@Inject public ThreadsListFragmentPresenter(FirebaseFirestore firebaseFirestore, FirebaseAuth firebaseAuth, VirgilHelper virgilHelper, DataReceivedInteractor<List<DefaultChatThread>> onDataReceivedInteractor, CompleteInteractor<ThreadListFragmentPresenterReturnTypes> completeInteractor) { this.firebaseFirestore = firebaseFirestore; this.firebaseAuth = firebaseAuth; this.virgilHelper = virgilHelper; this.onDataReceivedInteractor = onDataReceivedInteractor; this.completeInteractor = completeInteractor; compositeDisposable = new CompositeDisposable(); }