Java Code Examples for io.reactivex.disposables.CompositeDisposable#addAll()

The following examples show how to use io.reactivex.disposables.CompositeDisposable#addAll() . 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: StockViewModel.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
@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 2
Source File: StockViewModel.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
@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 3
Source File: StockViewModel.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
@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 4
Source File: StubComposeActivity.java    From Reactive-Android-Programming with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mock);

    disposable = new CompositeDisposable();

    Disposable disposable1 = Observable.interval(1, TimeUnit.SECONDS)
            .subscribe();

    Disposable disposable2 = Observable.interval(1, TimeUnit.SECONDS)
            .subscribe();

    Disposable disposable3 = Observable.interval(1, TimeUnit.SECONDS)
            .subscribe();

    disposable.addAll(
            disposable1,
            disposable2,
            disposable3
    );
}
 
Example 5
Source File: ModuleDriver.java    From AndroidGodEye with Apache License 2.0 4 votes vote down vote up
/**
 * 监听所有的数据
 */
public synchronized void start(Messager messager) {
    if (mIsRunning) {
        return;
    }
    mIsRunning = true;
    L.d("ModuleDriver start running.");
    mCompositeDisposable = new CompositeDisposable();
    mMessager = messager;
    mCompositeDisposable.addAll(
            RxModule.<BatteryInfo>wrapThreadComputationObservable(GodEye.ModuleName.BATTERY)
                    .map(BatteryInfoFactory.converter())
                    .map(this.createConvertServerMessageFunction("batteryInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<CpuInfo>wrapThreadComputationObservable(GodEye.ModuleName.CPU)
                    .map(this.createConvertServerMessageFunction("cpuInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<TrafficInfo>wrapThreadComputationObservable(GodEye.ModuleName.TRAFFIC)
                    .map(this.createConvertServerMessageFunction("trafficInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<FpsInfo>wrapThreadComputationObservable(GodEye.ModuleName.FPS)
                    .map(this.createConvertServerMessageFunction("fpsInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<LeakInfo>wrapThreadComputationObservable(GodEye.ModuleName.LEAK_CANARY)
                    .map(LeakConverter.leakConverter())
                    .map(this.createConvertServerMessageFunction("leakInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<BlockInfo>wrapThreadComputationObservable(GodEye.ModuleName.SM)
                    .map(blockMap())
                    .map(this.createConvertServerMessageFunction("blockInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<NetworkInfo>wrapThreadComputationObservable(GodEye.ModuleName.NETWORK)
                    .map(this.networkMap())
                    .map(this.createConvertServerMessageFunction("networkInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<StartupInfo>wrapThreadComputationObservable(GodEye.ModuleName.STARTUP)
                    .map(this.createConvertServerMessageFunction("startupInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<RamInfo>wrapThreadComputationObservable(GodEye.ModuleName.RAM)
                    .map(this.createConvertServerMessageFunction("ramInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<PssInfo>wrapThreadComputationObservable(GodEye.ModuleName.PSS)
                    .map(this.createConvertServerMessageFunction("pssInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<HeapInfo>wrapThreadComputationObservable(GodEye.ModuleName.HEAP)
                    .map(this.createConvertServerMessageFunction("heapInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<List<ThreadInfo>>wrapThreadComputationObservable(GodEye.ModuleName.THREAD)
                    .map(this.createConvertServerMessageFunction("threadInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<PageLifecycleEventInfo>wrapThreadComputationObservable(GodEye.ModuleName.PAGELOAD)
                    .map(this.pageLifecycleMap())
                    .map(this.createConvertServerMessageFunction("pageLifecycle"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<MethodsRecordInfo>wrapThreadComputationObservable(GodEye.ModuleName.METHOD_CANARY)
                    .map(this.createConvertServerMessageFunction("methodCanary"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<AppSizeInfo>wrapThreadComputationObservable(GodEye.ModuleName.APP_SIZE)
                    .map(this.createConvertServerMessageFunction("appSizeInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<ViewIssueInfo>wrapThreadComputationObservable(GodEye.ModuleName.VIEW_CANARY)
                    .map(this.createConvertServerMessageFunction("viewIssueInfo"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.<ImageIssue>wrapThreadComputationObservable(GodEye.ModuleName.IMAGE_CANARY)
                    .map(this.createConvertServerMessageFunction("imageIssue"))
                    .subscribe(this.createSendMessageConsumer()),
            RxModule.wrapThreadComputationObservable(CrashStore.observeCrashAndCache(GodEye.instance().getApplication(), "crash_of_debug_monitor"))
                    .filter(crashPredicate())
                    .map(this.createConvertServerMessageFunction("crashInfo"))
                    .subscribe(this.createSendMessageConsumer())
    );
}
 
Example 6
Source File: NotificationObserver.java    From AndroidGodEye with Apache License 2.0 4 votes vote down vote up
public synchronized void install(NotificationConfig godEyeNotificationConfig) {
    if (this.mNotificationListener == null) {
        return;
    }
    NotificationConsumer notificationConsumer = new NotificationConsumer(this.mNotificationListener);
    mCompositeDisposable = new CompositeDisposable();
    mCompositeDisposable.addAll(
            RxModule.<BatteryInfo>wrapThreadComputationObservable(GodEye.ModuleName.BATTERY)
                    .filter(godEyeNotificationConfig.batteryPredicate())
                    .map(godEyeNotificationConfig.batteryConverter())
                    .subscribe(notificationConsumer),
            RxModule.<CpuInfo>wrapThreadComputationObservable(GodEye.ModuleName.CPU)
                    .filter(godEyeNotificationConfig.cpuPredicate())
                    .map(godEyeNotificationConfig.cpuConverter())
                    .subscribe(notificationConsumer),
            RxModule.<TrafficInfo>wrapThreadComputationObservable(GodEye.ModuleName.TRAFFIC)
                    .filter(godEyeNotificationConfig.trafficPredicate())
                    .map(godEyeNotificationConfig.trafficConverter())
                    .subscribe(notificationConsumer),
            RxModule.<FpsInfo>wrapThreadComputationObservable(GodEye.ModuleName.FPS)
                    .filter(godEyeNotificationConfig.fpsPredicate())
                    .map(godEyeNotificationConfig.fpsConverter())
                    .subscribe(notificationConsumer),
            RxModule.<LeakInfo>wrapThreadComputationObservable(GodEye.ModuleName.LEAK_CANARY)
                    .filter(godEyeNotificationConfig.leakPredicate())
                    .map(godEyeNotificationConfig.leakConverter())
                    .subscribe(notificationConsumer),
            RxModule.<BlockInfo>wrapThreadComputationObservable(GodEye.ModuleName.SM)
                    .filter(godEyeNotificationConfig.smPredicate())
                    .map(godEyeNotificationConfig.smConverter())
                    .subscribe(notificationConsumer),
            RxModule.<NetworkInfo>wrapThreadComputationObservable(GodEye.ModuleName.NETWORK)
                    .filter(godEyeNotificationConfig.networkPredicate())
                    .map(godEyeNotificationConfig.networkConverter())
                    .subscribe(notificationConsumer),
            RxModule.<StartupInfo>wrapThreadComputationObservable(GodEye.ModuleName.STARTUP)
                    .filter(godEyeNotificationConfig.startupPredicate())
                    .map(godEyeNotificationConfig.startupConverter())
                    .subscribe(notificationConsumer),
            RxModule.<RamInfo>wrapThreadComputationObservable(GodEye.ModuleName.RAM)
                    .filter(godEyeNotificationConfig.ramPredicate())
                    .map(godEyeNotificationConfig.ramConverter())
                    .subscribe(notificationConsumer),
            RxModule.<PssInfo>wrapThreadComputationObservable(GodEye.ModuleName.PSS)
                    .filter(godEyeNotificationConfig.pssPredicate())
                    .map(godEyeNotificationConfig.pssConverter())
                    .subscribe(notificationConsumer),
            RxModule.<HeapInfo>wrapThreadComputationObservable(GodEye.ModuleName.HEAP)
                    .filter(godEyeNotificationConfig.heapPredicate())
                    .map(godEyeNotificationConfig.heapConverter())
                    .subscribe(notificationConsumer),
            RxModule.<List<ThreadInfo>>wrapThreadComputationObservable(GodEye.ModuleName.THREAD)
                    .filter(godEyeNotificationConfig.threadPredicate())
                    .map(godEyeNotificationConfig.threadConverter())
                    .subscribe(notificationConsumer),
            RxModule.<PageLifecycleEventInfo>wrapThreadComputationObservable(GodEye.ModuleName.PAGELOAD)
                    .filter(godEyeNotificationConfig.pageloadPredicate())
                    .map(godEyeNotificationConfig.pageloadConverter())
                    .subscribe(notificationConsumer),
            RxModule.<MethodsRecordInfo>wrapThreadComputationObservable(GodEye.ModuleName.METHOD_CANARY)
                    .filter(godEyeNotificationConfig.methodCanaryPredicate())
                    .map(godEyeNotificationConfig.methodCanaryConverter())
                    .subscribe(notificationConsumer),
            RxModule.<AppSizeInfo>wrapThreadComputationObservable(GodEye.ModuleName.APP_SIZE)
                    .filter(godEyeNotificationConfig.appSizePredicate())
                    .map(godEyeNotificationConfig.appSizeConverter())
                    .subscribe(notificationConsumer),
            RxModule.<ViewIssueInfo>wrapThreadComputationObservable(GodEye.ModuleName.VIEW_CANARY)
                    .filter(godEyeNotificationConfig.viewCanaryPredicate())
                    .map(godEyeNotificationConfig.viewCanaryConverter())
                    .subscribe(notificationConsumer),
            RxModule.<ImageIssue>wrapThreadComputationObservable(GodEye.ModuleName.IMAGE_CANARY)
                    .filter(godEyeNotificationConfig.imageCanaryPredicate())
                    .map(godEyeNotificationConfig.imageCanaryConverter())
                    .subscribe(notificationConsumer),
            RxModule.wrapThreadComputationObservable(CrashStore.observeCrashAndCache(GodEye.instance().getApplication(), "crash_of_notification"))
                    .filter(godEyeNotificationConfig.crashPredicate())
                    .map(godEyeNotificationConfig.crashConverter())
                    .subscribe(notificationConsumer)
    );
    this.mNotificationListener.onInstalled();
}