本文整理汇总了Java中io.reactivex.disposables.CompositeDisposable类的典型用法代码示例。如果您正苦于以下问题:Java CompositeDisposable类的具体用法?Java CompositeDisposable怎么用?Java CompositeDisposable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompositeDisposable类属于io.reactivex.disposables包,在下文中一共展示了CompositeDisposable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QuestionPresenter
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
QuestionPresenter(QuestionContract.View view, RequestFactory requestFactory,
TriviaSharedPreferences triviaSharedPreferences, int amount, String categoryId,
String difficulty, String questionType) {
this.view = view;
this.requestFactory = requestFactory;
this.triviaSharedPreferences = triviaSharedPreferences;
this.amount = amount;
this.categoryId = categoryId;
this.difficulty = difficulty;
this.questionType = questionType;
sessionToken = triviaSharedPreferences.getSessionToken();
questionsList = new ArrayList<>();
questionPosition = 0;
numberOfCorrectAnswers = 0;
compositeDisposable = new CompositeDisposable();
view.setPresenter(this);
}
示例2: onBindViewHolder
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
@Override
public void onBindViewHolder(ChapterViewHolder holder, int position) {
CompositeDisposable compositeDisposable = new CompositeDisposable();
holder.binding.webview.loadUrl(BLANK_URL);
holder.binding.webview.setUrlInterceptor(strategy.urlInterceptor);
SpineReference spineReference = epub.getBook().getSpine().getSpineReferences().get(position);
holder.binding.webview.loadEpubPage(epub, spineReference, epubView.getSettings());
Bridge bridge = new Bridge();
holder.binding.webview.setInternalBridge(bridge);
handleLocation(position, holder.binding.webview);
bridge.xPath()
.doOnNext(xPath -> {
EpubLocation location = EpubLocation.fromXPath(strategy.getCurrentChapter(), xPath);
strategy.setCurrentLocation(location);
})
.subscribeWith(new BaseDisposableObserver<>())
.addTo(compositeDisposable);
}
示例3: test
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
@Test public void test() {
CompletableSubject subject = CompletableSubject.create();
Completable source = subject.hide();
TestObserver testObserver = new TestObserver();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = source
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testObserver);
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testObserver.isDisposed());
}
示例4: test
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
@Test public void test() {
MaybeSubject<String> subject = MaybeSubject.create();
Maybe<String> maybeSource = subject.hide();
TestObserver testObserver = new TestObserver();
CompositeDisposable composite = new CompositeDisposable();
Disposable disposable = maybeSource
.compose(DisposableAttach.<String>to(composite))
.subscribeWith(testObserver);
subject.onSuccess("Foo");
testObserver.assertValue("Foo");
assertTrue(composite.size() == 1);
composite.dispose();
assertTrue(composite.size() == 0);
assertTrue(composite.isDisposed());
assertTrue(disposable.isDisposed());
assertTrue(testObserver.isDisposed());
}
示例5: setupLyricsView
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
private void setupLyricsView() {
mDisposable = new CompositeDisposable();
//mLyricView.setLineSpace(15.0f);
mLyricView.setTextSize(fontSize);
//mLyricView.setTranslationY(DensityUtil.getScreenWidth(getActivity()) + DensityUtil.dip2px(getActivity(), 120));
mLyricView.setOnPlayerClickListener(new LyricView.OnPlayerClickListener() {
@Override
public void onPlayerClicked(long progress, String content) {
MusicPlayerRemote.seekTo((int) progress);
}
});
rotate();
//mLyricView.setTouchable(true);
//mLyricView.setPlayable(true);
//mLyricView.setDefaultColor(Color.WHITE);
}
示例6: onCreate
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
@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_album_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));
}
示例7: onCreateView
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle args = getArguments();
mAccountInfoType = AccountInfoType.safeValueOf( args.getString( ARG_INFO_TYPE));
mCompositeDisposable = new CompositeDisposable();
View view = inflater.inflate(R.layout.dialog_input_account, container, false);
ActivityComponent component = getActivityComponent();
if (component != null) {
component.inject(this);
}
return view;
}
示例8: onCreate
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mLoginObservable = Observable
.timer(TIME_DELAY, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
.map(aLong -> "User id is " + UUID.randomUUID().toString());
mLoginFlowable = Flowable
.timer(TIME_DELAY, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
.map(aLong -> "User id is " + UUID.randomUUID().toString());
mCompositeDisposable = new CompositeDisposable();
findViewById(R.id.button_observable).setOnClickListener(this);
findViewById(R.id.button_flowable).setOnClickListener(this);
}
示例9: integrationLoginTestScenario2
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
/**
* {@link ProjectRepository} login() api call
* - get accessToken after successful login (failed)
*/
@Test
public void integrationLoginTestScenario2() throws Exception {
Assert.assertEquals(projectRepository.getRepositoryState(),
ProjectRepository.repositoryStates.INIT);
Assert.assertNull(projectRepository.getData());
CompositeDisposable disposable = new CompositeDisposable();
disposable.add(projectRepository.login(dummyApiBadUrl, targetContext, dummyLogin, dummyPassword)
.subscribeOn(Schedulers.io())
.doOnError(throwable -> Assert.fail())
.subscribe(appDataRxResponse -> {
Assert.assertNotNull(appDataRxResponse);
Assert.assertNull(appDataRxResponse.data);
Assert.assertEquals(RxStatus.LOGIN_ERROR, appDataRxResponse.status);
disposable.dispose();
}));
}
示例10: onCreate
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sp = PreferenceManager.getDefaultSharedPreferences(this);
checkPermission();
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mCompositeDisposable = new CompositeDisposable();
initRecyclerView();
loadProviders();
// mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
// mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
// @Override
// public void onRefresh() {
// mRefreshLayout.setRefreshing(true);
// loadProviders();
// runLayoutAnimation();
// mRefreshLayout.setRefreshing(false);
// }
// });
}
示例11: InitView
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
public void InitView()
{
//init Composite
mCompositeDisposable = new CompositeDisposable();
//init AppCompatButton
btn_loading_observe=(AppCompatButton)findViewById(R.id.btn_loading_observe);
btn_loadig_flowable=(AppCompatButton)findViewById(R.id.btn_loading_flowable);
//btn observe
btn_loading_observe.setOnClickListener(view->{
mCompositeDisposable.add(RxProgress.from(MainActivity.this)
.withMessage("Logging in...")
.forObservable(user_Observable)
.subscribe(id -> getMessage(id),
throwable -> Log.w(TAG, throwable.getMessage())));
});
//btn Flowable
btn_loadig_flowable.setOnClickListener(view ->{
mCompositeDisposable.add(RxProgress.from(MainActivity.this)
.forFlowable(user_Flowable, BackpressureStrategy.DROP)
.subscribe(id -> getMessage(id),
throwable -> Log.w(TAG, throwable.getMessage())));
} );
}
示例12: MonthAdapter
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
public MonthAdapter(Context context, DateTime currentMonth) {
this.context = context;
this.subscriptions = new CompositeDisposable();
this.calendar = AUCalendar.getInstance();
this.layoutResId = R.layout.calendar_cell;
this.currentMonth = currentMonth.withDayOfMonth(1).withMillisOfDay(0);
initFromCalendar();
subscribe();
}
示例13: before
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
@CallSuper
@Before
public void before() {
initMocks(this);
testScheduler = new TestScheduler();
compositeDisposableHelper = new CompositeDisposableHelper(new CompositeDisposable(),
new TestSchedulerProvider(testScheduler));
view = createView();
presenter = createPresenter();
presenter.attachView(view);
}
示例14: onCreate
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
Toothpick.inject(this, Toothpick.openScopes(RxNetwork.class, this));
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
subscriptions = new CompositeDisposable();
}
示例15: addSubscription
import io.reactivex.disposables.CompositeDisposable; //导入依赖的package包/类
/**
* 保存订阅后的disposable
* @param o
* @param disposable
*/
public void addSubscription(Object o, Disposable disposable) {
if (mSubscriptionMap == null) {
mSubscriptionMap = new HashMap<>();
}
String key = o.getClass().getName();
if (mSubscriptionMap.get(key) != null) {
mSubscriptionMap.get(key).add(disposable);
} else {
//一次性容器,可以持有多个并提供 添加和移除。
CompositeDisposable disposables = new CompositeDisposable();
disposables.add(disposable);
mSubscriptionMap.put(key, disposables);
}
}