当前位置: 首页>>代码示例>>Java>>正文


Java CompositeDisposable.add方法代码示例

本文整理汇总了Java中io.reactivex.disposables.CompositeDisposable.add方法的典型用法代码示例。如果您正苦于以下问题:Java CompositeDisposable.add方法的具体用法?Java CompositeDisposable.add怎么用?Java CompositeDisposable.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.disposables.CompositeDisposable的用法示例。


在下文中一共展示了CompositeDisposable.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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));

}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:24,代码来源:AlbumsArtDownloadService.java

示例2: 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_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));

}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:24,代码来源:ArtistArtDownloadService.java

示例3: 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();
            }));
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:25,代码来源:ProjectRepositoryIntegrationTest.java

示例4: init

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
@Override
public void init() {
    mDisposables = new CompositeDisposable();
    mDisposables.add(Observable.timer(TIME_TO_MAINACTIVITY, TimeUnit.MILLISECONDS)
            .subscribe(new Consumer<Long>() {
                @Override
                public void accept(@NonNull Long aLong) throws Exception {
                    launchMainActivity();
                }
            }));
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:12,代码来源:SplashActivity.java

示例5: findAnnotatedMethods

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
private static EventComposite findAnnotatedMethods(Object listenerClass, Set<EventSubscriber> subscriberMethods,
                                                   CompositeDisposable compositeDisposable) {
    for (Method method : listenerClass.getClass().getDeclaredMethods()) {
        if (method.isBridge()) {
            continue;
        }
        if (method.isAnnotationPresent(Subscribe.class)) {
            Class<?>[] parameterTypes = method.getParameterTypes();
            if (parameterTypes.length != 1) {
                throw new IllegalArgumentException("Method " + method + " has @Subscribe annotation but requires " + parameterTypes
                        .length + " arguments.  Methods must require a single argument.");
            }

            Class<?> parameterClazz = parameterTypes[0];
            if ((method.getModifiers() & Modifier.PUBLIC) == 0) {
                throw new IllegalArgumentException("Method " + method + " has @EventSubscribe annotation on " + parameterClazz + " " +
                        "but is not 'public'.");
            }

            Subscribe annotation = method.getAnnotation(Subscribe.class);
            ThreadMode thread = annotation.threadMode();

            EventSubscriber subscriberEvent = new EventSubscriber(listenerClass, method, thread);
            if (!subscriberMethods.contains(subscriberEvent)) {
                subscriberMethods.add(subscriberEvent);//添加事件订阅者
                compositeDisposable.add(subscriberEvent.getDisposable());//管理订阅,方便取消订阅
            }
        }
    }
    return new EventComposite(compositeDisposable, listenerClass, subscriberMethods);
}
 
开发者ID:xiaoyaoyou1212,项目名称:XSnow,代码行数:32,代码来源:EventFind.java

示例6: onCreate

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_login);
    initializeViews();
    disposables = new CompositeDisposable();

    Disposable disposable = RxView.clicks(findViewById(R.id.fab))
            .map(ignoredObject ->
                    !TextUtils.isEmpty(firstNameEditText.getText().toString())
                            && !TextUtils.isEmpty(lastNameEditText.getText().toString())
                            && !TextUtils.isEmpty(lastNameEditText.getText().toString())
            )
            .subscribe(isInputValid -> {
                if (isInputValid) {
                    Intent responseData = new Intent();
                    responseData.putExtra(LAST_NAME, lastNameEditText.getText().toString());
                    responseData.putExtra(FIRST_NAME, firstNameEditText.getText().toString());
                    responseData.putExtra(EMAIL_ADDRESS, emailAddressEditText.getText().toString());
                    setResult(RESULT_OK, responseData);
                    finish();
                } else {
                    Snackbar snackbar = Snackbar.make(
                            findViewById(R.id.login_content),
                            R.string.all_fields_required,
                            Snackbar.LENGTH_SHORT);
                    snackbar.setAction(android.R.string.ok, view -> {}).show();
                }
            });

    disposables.add(disposable);

}
 
开发者ID:mohamad-amin,项目名称:RxActivityResults,代码行数:36,代码来源:LoginActivity.java

示例7: bind

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
public static Disposable bind(ItemEpubVerticalContentBinding binding) {
    CompositeDisposable compositeDisposable = new CompositeDisposable();

    compositeDisposable.add(bindSeekbar(binding));
    compositeDisposable.add(bindProgressBar(binding));

    return compositeDisposable;
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:9,代码来源:VerticalContentBinderHelper.java

示例8: getView

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
@Override
public View getView(int position, ViewGroup parent) {
    CompositeDisposable compositeDisposable = chapterDisposables.get(position);
    if (compositeDisposable == null) {
        chapterDisposables.append(position, new CompositeDisposable());
        compositeDisposable = chapterDisposables.get(position);
    }

    ItemEpubVerticalContentBinding binding = ItemEpubVerticalContentBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);

    binding.webview.setUrlInterceptor(strategy.urlInterceptor);

    SpineReference spineReference = epub.getBook().getSpine().getSpineReferences().get(position);
    binding.webview.loadEpubPage(epub, spineReference, epubView.getSettings());

    handleLocation(position, binding.webview);

    binding.webview.bindToSettings(epubView.getSettings());

    InternalEpubBridge bridge = new InternalEpubBridge();
    binding.webview.setInternalBridge(bridge);

    bridge.xPath()
            .doOnNext(xPath -> {
                EpubLocation location = EpubLocation.fromXPath(strategy.getCurrentChapter(), xPath);
                chapterLocations.append(position, location);
                strategy.setCurrentLocation(location);
            })
            .subscribeWith(new BaseDisposableObserver<>())
            .addTo(compositeDisposable);

    compositeDisposable.add(VerticalContentBinderHelper.bind(binding));

    return binding.root;
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:36,代码来源:PagerAdapter.java

示例9: main

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
public static void main(String[] args) {
	// TODO Auto-generated method stub
	CompositeDisposable disposable = new CompositeDisposable();
	disposable.add(Flowable.rangeLong(10, 5).subscribe(System.out::println));
	disposable.add(Flowable.rangeLong(1, 5).subscribe(item -> System.out.println("two" + item)));

	disposable.add(Observable.create(new ObservableOnSubscribe<String>() {

		@Override
		public void subscribe(ObservableEmitter<String> emitter) throws Exception {
			// TODO Auto-generated method stub

			try {
				String[] monthArray = { "Jan", "Feb", "Mar", "Apl", "May", "Jun", "July", "Aug", "Sept", "Oct",
						"Nov", "Dec" };

				List<String> months = Arrays.asList(monthArray);

				for (String month : months) {
					emitter.onNext(month);
				}
				emitter.onComplete();
			} catch (Exception e) {
				// TODO: handle exception
				emitter.onError(e);
			}
		}
	}).subscribe(s -> System.out.println(s)));

	disposable.dispose();

	
}
 
开发者ID:PacktPublishing,项目名称:Reactive-Programming-With-Java-9,代码行数:34,代码来源:DemoCompositeDisposable.java

示例10: 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);
    }
}
 
开发者ID:simplezhli,项目名称:RxPay,代码行数:20,代码来源:BusUtil.java

示例11: integrationDataTestScenario2

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
/**
 * {@link ProjectRepository} getAppData() / getData() integration test scenario 2
 * - check init ProjectRepository state
 * - get appData API response (failed)
 */
@Test
public void integrationDataTestScenario2() throws Exception {
    Assert.assertEquals(projectRepository.getRepositoryState(),
            ProjectRepository.repositoryStates.INIT);
    Assert.assertNull(projectRepository.getData());

    projectRepository.setAccessToken(dummyToken);

    CompositeDisposable disposable = new CompositeDisposable();

    disposable.add(projectRepository.getAppData(dummyApiBadUrl, targetContext)
            .subscribeOn(Schedulers.io())
            .doOnError(throwable -> Assert.fail())
            .subscribe(appDataRxResponse -> {

                Assert.assertNotNull(appDataRxResponse);
                Assert.assertNull(appDataRxResponse.data);
                Assert.assertNotNull(appDataRxResponse.error);
                Assert.assertEquals(RxStatus.ERROR, appDataRxResponse.status);

                Assert.assertEquals(projectRepository.getRepositoryState(),
                        ProjectRepository.repositoryStates.ERROR);

                disposable.dispose();
            }));
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:32,代码来源:ProjectRepositoryIntegrationTest.java

示例12: integrationUpdateTestScenario3

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
/**
 * {@link ProjectRepository} getUpdate() integration test scenario 3
 * - get API last update id (failed)
 * - load AppData from local db
 * - check ProjectRepository after successful load
 */
@Test
public void integrationUpdateTestScenario3() throws Exception {
    Assert.assertEquals(projectRepository.getRepositoryState(),
            ProjectRepository.repositoryStates.INIT);
    Assert.assertNull(projectRepository.getData());

    projectRepository.setAccessToken(dummyToken);

    Gson gson = new Gson();
    AppData appData = gson.fromJson(
            readAssetFile(testContext, "api/app_data.json"), AppData.class);

    CompositeDisposable disposable = new CompositeDisposable();

    disposable.add(projectRepository.getUpdate(dummyApiBadUrl, targetContext)
            .subscribeOn(Schedulers.io())
            .doOnError(throwable -> Assert.fail())
            .subscribe(appDataRxResponse -> {

                Assert.assertNotNull(appDataRxResponse);
                Assert.assertNotNull(appDataRxResponse.data); //fails because local db load not implemented
                Assert.assertNull(appDataRxResponse.error);
                Assert.assertEquals(RxStatus.SUCCESS, appDataRxResponse.status);
                Assert.assertEquals(appData, appDataRxResponse.data);
                Assert.assertEquals(appData.hashCode(), appDataRxResponse.data.hashCode());

                Assert.assertEquals(projectRepository.getRepositoryState(),
                        ProjectRepository.repositoryStates.READY);

                Assert.assertNotNull(projectRepository.getData());
                Assert.assertEquals(projectRepository.getData().data, appData);

                disposable.dispose();

            }));
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:43,代码来源:ProjectRepositoryIntegrationTest.java

示例13: addDisposable

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
private void addDisposable(Disposable disposable, FragmentEvent event) {
    CompositeDisposable d = getDisposable(event);
    d.add(disposable);
}
 
开发者ID:mahmed8003,项目名称:RxLifecycle,代码行数:5,代码来源:RxFragment.java

示例14: addDisposable

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
private void addDisposable(Disposable disposable, ActivityEvent event) {
    CompositeDisposable d = getDisposable(event);
    d.add(disposable);
}
 
开发者ID:mahmed8003,项目名称:RxLifecycle,代码行数:5,代码来源:RxActivity.java

示例15: addTo

import io.reactivex.disposables.CompositeDisposable; //导入方法依赖的package包/类
public void addTo(CompositeDisposable compositeDisposable) {
    compositeDisposable.add(this);
}
 
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:4,代码来源:BaseDisposableObserver.java


注:本文中的io.reactivex.disposables.CompositeDisposable.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。