rx.subjects.PublishSubject Java Examples
The following examples show how to use
rx.subjects.PublishSubject.
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: UploadManager.java From RxUploader with Apache License 2.0 | 6 votes |
@NonNull public UploadManager build() { if (uploadService == null) { throw new IllegalArgumentException("Must provide a valid upload service"); } if (uploadDataStore == null) { throw new IllegalArgumentException("Must provide a valid upload data store"); } if (uploadErrorAdapter == null) { throw new IllegalArgumentException("Must provide a valid upload error adapter"); } final Subject<Job, Job> jobSubject = PublishSubject.<Job>create().toSerialized(); final Subject<Status, Status> statusSubject = PublishSubject.<Status>create().toSerialized(); final Uploader uploader = Uploader.create(uploadService); final UploadInteractor uploadInteractor = UploadInteractorImpl.create(uploader, uploadDataStore, uploadErrorAdapter); return new UploadManager(uploadInteractor, uploadErrorAdapter, jobSubject, statusSubject, deleteRecordOnComplete); }
Example #2
Source File: OperatorFromTransformerTest.java From rxjava-extras with Apache License 2.0 | 6 votes |
@Test public void testErrorsPassedThroughToOperator() { PublishSubject<Integer> subject = PublishSubject.create(); Recorder recorder1 = new Recorder(); Recorder recorder2 = new Recorder(); subject.subscribe(recorder1); subject.subscribe(recorder2); subject.onNext(1); assertEquals(asList(1), recorder1.list()); assertEquals(asList(1), recorder2.list()); subject.onNext(2); assertEquals(asList(1, 2), recorder1.list()); assertEquals(asList(1, 2), recorder2.list()); Exception e = new Exception("boo"); assertTrue(recorder1.errors().isEmpty()); assertTrue(recorder2.errors().isEmpty()); subject.onError(e); assertEquals(asList(e), recorder1.errors()); assertEquals(asList(e), recorder2.errors()); }
Example #3
Source File: NingRequestBuilder.java From ob1k with Apache License 2.0 | 6 votes |
@Override public <T> Observable<TypedResponse<T>> asTypedStream(final Type type) { try { prepareRequestBody(); } catch (final IOException e) { return Observable.error(e); } setRequestTimeout(-1); final PublishSubject<TypedResponse<T>> result = PublishSubject.create(); final NingHttpTypedStreamHandler<T> handler = new NingHttpTypedStreamHandler<>(responseMaxSize, result, marshallingStrategy, type); ningRequestBuilder.execute(handler); return result; }
Example #4
Source File: ListStoreAppsPresenterTest.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Test public void loadAppsAfterRefreshWithGenericError() { //Given an initialized ListStoreAppsPresenter with a STORE_ID and a limit of apps //When onCreate lifecycle call event happens //and the view is refreshed by the user PublishSubject<Void> refreshEvent = PublishSubject.create(); when(view.getRefreshEvent()).thenReturn(refreshEvent); when(appCenter.loadFreshApps(STORE_ID_TEST, LIMIT_APPS_TEST)).thenReturn( Single.just(appsModelWithGenericError)); listStoreAppsPresenter.present(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); refreshEvent.onNext(null); //Then when new apps are requested verify(appCenter).loadFreshApps(STORE_ID_TEST, LIMIT_APPS_TEST); //hide refresh loading verify(view).hideRefreshLoading(); // and show Generic error verify(view).showGenericError(); }
Example #5
Source File: X8VerticalSeekBarValueLayout.java From FimiX8-RE with MIT License | 6 votes |
private void runRxAnroid() { this.mSearchResultsSubject = PublishSubject.create(); this.mTextWatchSubscription = this.mSearchResultsSubject.throttleLast(500, TimeUnit.MILLISECONDS).observeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<Integer>() { public void onCompleted() { } public void onError(Throwable e) { } public void onNext(Integer cities) { if (X8VerticalSeekBarValueLayout.this.lastValue != cities.intValue()) { X8VerticalSeekBarValueLayout.this.lastValue = cities.intValue(); X8VerticalSeekBarValueLayout.this.sendJsonCmdSetFocuse(X8VerticalSeekBarValueLayout.this.lastValue); } } }); }
Example #6
Source File: Example_8_Model.java From Java_MVVM_with_Swing_and_RxJava_Examples with Apache License 2.0 | 6 votes |
public Observable<LogRow> getLogs() { SerializedSubject<LogRow, LogRow> subject = new SerializedSubject<>(PublishSubject.create()); ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat(Example_8_Model.class.getSimpleName() + "-thread-%d").build(); final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), threadFactory); IntStream.range(1, Runtime.getRuntime().availableProcessors() + 1).forEach(value -> { executorService.submit(() -> { SysOutUtils.sysout(Thread.currentThread().getName() + " will briefly start creating lots of log rows..."); VariousUtils.sleep(1000); long incrementingNumber = 1; while (true) { subject.onNext(new LogRow( DateTimeFormatter.ISO_DATE_TIME.format(LocalDateTime.now()), "Status " + Integer.toString(ThreadLocalRandom.current().nextInt(1, 5)), "Action " + incrementingNumber + " from " + Thread.currentThread().getName())); } }); }); return subject; }
Example #7
Source File: PushServers.java From mantis with Apache License 2.0 | 6 votes |
public static <T> LegacyTcpPushServer<T> infiniteStreamLegacyTcpNested(ServerConfig<T> config, Observable<Observable<T>> o) { final PublishSubject<String> serverSignals = PublishSubject.create(); final String serverName = config.getName(); Action0 onComplete = new Action0() { @Override public void call() { serverSignals.onNext("ILLEGAL_STATE_COMPLETED"); throw new IllegalStateException("OnComplete signal received, Server: " + serverName + " is pushing an infinite stream, should not complete"); } }; Action1<Throwable> onError = new Action1<Throwable>() { @Override public void call(Throwable t) { serverSignals.onError(t); } }; PushTrigger<T> trigger = ObservableTrigger.oo(serverName, o, onComplete, onError); return new LegacyTcpPushServer<T>(trigger, config, serverSignals); }
Example #8
Source File: DynamicConnectionSet.java From mantis with Apache License 2.0 | 6 votes |
public static <K, V> DynamicConnectionSet<GroupedObservable<K, V>> create( final ConnectToGroupedObservable.Builder<K, V> config, int maxTimeBeforeDisconnectSec) { Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<GroupedObservable<K, V>>> toObservableFunc = new Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<GroupedObservable<K, V>>>() { @Override public RemoteRxConnection<GroupedObservable<K, V>> call(Endpoint endpoint, Action0 disconnectCallback, PublishSubject<Integer> closeConnectionTrigger) { // copy config, change host, port and id ConnectToGroupedObservable.Builder<K, V> configCopy = new ConnectToGroupedObservable.Builder<K, V>(config); configCopy .host(endpoint.getHost()) .port(endpoint.getPort()) .closeTrigger(closeConnectionTrigger) .connectionDisconnectCallback(disconnectCallback) .slotId(endpoint.getSlotId()); return RemoteObservable.connect(configCopy.build()); } }; return new DynamicConnectionSet<GroupedObservable<K, V>>(toObservableFunc, MIN_TIME_SEC_DEFAULT, maxTimeBeforeDisconnectSec); }
Example #9
Source File: DynamicConnectionSet.java From mantis with Apache License 2.0 | 6 votes |
public static <K, V> DynamicConnectionSet<MantisGroup<K, V>> createMGO( final ConnectToGroupedObservable.Builder<K, V> config, int maxTimeBeforeDisconnectSec, final SpscArrayQueue<MantisGroup<?, ?>> inputQueue) { Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<MantisGroup<K, V>>> toObservableFunc = new Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<MantisGroup<K, V>>>() { @Override public RemoteRxConnection<MantisGroup<K, V>> call(Endpoint endpoint, Action0 disconnectCallback, PublishSubject<Integer> closeConnectionTrigger) { // copy config, change host, port and id ConnectToGroupedObservable.Builder<K, V> configCopy = new ConnectToGroupedObservable.Builder<K, V>(config); configCopy .host(endpoint.getHost()) .port(endpoint.getPort()) .closeTrigger(closeConnectionTrigger) .connectionDisconnectCallback(disconnectCallback) .slotId(endpoint.getSlotId()); return RemoteObservable.connectToMGO(configCopy.build(), inputQueue); } }; return new DynamicConnectionSet<MantisGroup<K, V>>(toObservableFunc, MIN_TIME_SEC_DEFAULT, maxTimeBeforeDisconnectSec); }
Example #10
Source File: ListStoreAppsPresenterTest.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Test public void loadAppsAfterRefreshWithLoadingError() { //Given an initialized ListStoreAppsPresenter with a STORE_ID and a limit of apps //When onCreate lifecycle call event happens //and the view is refreshed by the user //and the app model is processing another request PublishSubject<Void> refreshEvent = PublishSubject.create(); when(view.getRefreshEvent()).thenReturn(refreshEvent); when(appCenter.loadFreshApps(STORE_ID_TEST, LIMIT_APPS_TEST)).thenReturn( Single.just(appsModelLoading)); listStoreAppsPresenter.present(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); refreshEvent.onNext(null); //Then when new apps are requested verify(appCenter).loadFreshApps(STORE_ID_TEST, LIMIT_APPS_TEST); //and apps model is loading //hide loading verify(view).hideRefreshLoading(); //and do nothing else verify(view, never()).setApps(appsModelLoading.getList()); verify(view, never()).showGenericError(); verify(view, never()).showNetworkError(); }
Example #11
Source File: TransformersTest.java From mobius with Apache License 2.0 | 6 votes |
@Test public void processingLongEffectsDoesNotBlockProcessingShorterEffects() { final List<String> effects = Arrays.asList("Hello", "Rx"); PublishSubject<String> upstream = PublishSubject.create(); Function<String, Integer> sleepyFunction = s -> { try { Thread.sleep(duration(s)); } catch (InterruptedException ie) { } return s.length(); }; final List<Integer> results = new ArrayList<>(); upstream .compose(Transformers.fromFunction(sleepyFunction, Schedulers.io())) .subscribe(results::add); Observable.from(effects).subscribe(upstream); await().atMost(durationForEffects(effects)).until(() -> results.equals(expected(effects))); }
Example #12
Source File: RetryFileDownloadManager.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
private Observable<FileDownloadCallback> handleFileDownloadProgress( FileDownloader fileDownloader) { return fileDownloader.observeFileDownloadProgress() .takeUntil(fileDownloadCallback -> fileDownloadCallback.getDownloadState() == AppDownloadStatus.AppDownloadState.ERROR_FILE_NOT_FOUND) .flatMap(fileDownloadCallback -> { if (fileDownloadCallback.getDownloadState() == AppDownloadStatus.AppDownloadState.ERROR_FILE_NOT_FOUND && !retried) { Logger.getInstance() .d(TAG, "File not found error, restarting the download with the alternative link"); FileDownloader retryFileDownloader = fileDownloaderProvider.createFileDownloader(md5, alternativeDownloadPath, fileType, packageName, versionCode, fileName, PublishSubject.create()); retried = true; this.fileDownloader = retryFileDownloader; return retryFileDownloader.startFileDownload() .andThen(handleFileDownloadProgress(retryFileDownloader)); } else { return Observable.just(fileDownloadCallback); } }) .doOnNext(fileDownloadCallback -> retryFileDownloadSubject.onNext(fileDownloadCallback)); }
Example #13
Source File: FlatMapCompletableTest.java From mobius with Apache License 2.0 | 6 votes |
@Test public void errorsPropagateDownTheChain() { PublishSubject<Integer> upstream = PublishSubject.create(); FlatMapCompletable<Integer, SomeOtherType> flatMapCompletable = FlatMapCompletable.createForAction( new Action1<Integer>() { @Override public void call(Integer integer) { throw new IllegalArgumentException(); } }); Observable<SomeOtherType> observable = upstream.compose(flatMapCompletable); TestSubscriber<SomeOtherType> subscriber = new TestSubscriber<>(); observable.subscribe(subscriber); upstream.onNext(1); subscriber.assertNoValues(); subscriber.assertError(IllegalArgumentException.class); }
Example #14
Source File: MobiusEffectRouterTest.java From mobius with Apache License 2.0 | 6 votes |
@Test public void effectHandlersShouldBeImmutable() throws Exception { // redo some test setup for test case specific conditions publishSubject = PublishSubject.create(); testSubscriber = TestSubscriber.create(); RxMobius.SubtypeEffectHandlerBuilder<TestEffect, TestEvent> builder = RxMobius.<TestEffect, TestEvent>subtypeEffectHandler() .addTransformer(A.class, (Observable<A> as) -> as.map(a -> AEvent.create(a.id()))); Transformer<TestEffect, TestEvent> router = builder.build(); // this should not lead to the effects router being capable of handling B effects builder.addTransformer(B.class, (Observable<B> bs) -> bs.map(b -> BEvent.create(b.id()))); publishSubject.compose(router).subscribe(testSubscriber); B effect = B.create(84); publishSubject.onNext(effect); publishSubject.onCompleted(); testSubscriber.awaitTerminalEvent(3, TimeUnit.SECONDS); testSubscriber.assertError(new UnknownEffectException(effect)); }
Example #15
Source File: RxConnectablesTest.java From mobius with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { input = PublishSubject.create(); connectable = new Connectable<String, Integer>() { @Nonnull @Override public Connection<String> connect(final Consumer<Integer> output) throws ConnectionLimitExceededException { return new Connection<String>() { @Override public void accept(String value) { if (value.equals("crash")) { throw new RuntimeException("crashing!"); } output.accept(value.length()); } @Override public void dispose() {} }; } }; }
Example #16
Source File: RateLimitedBatcherTest.java From titus-control-plane with Apache License 2.0 | 6 votes |
@Test public void ignoreErrorsFromDownstream() { final Instant now = Instant.ofEpochMilli(testScheduler.now()); final RateLimitedBatcher<BatchableOperationMock, String> batcher = buildBatcher(minimumTimeInQueueMs); final Subject<BatchableOperationMock, BatchableOperationMock> updates = PublishSubject.<BatchableOperationMock>create().toSerialized(); final AssertableSubscriber<?> subscriber = updates.lift(batcher) .lift(new ExceptionThrowingOperator("some error happened")) .test(); testScheduler.triggerActions(); subscriber.assertNoTerminalEvent().assertNoValues(); for (int i = 0; i < 10; i++) { updates.onNext(new BatchableOperationMock(LOW, now, "resource2", "sub2", "create")); testScheduler.advanceTimeBy(minimumTimeInQueueMs, TimeUnit.MILLISECONDS); subscriber.assertNoTerminalEvent().assertNoValues(); } updates.onCompleted(); testScheduler.advanceTimeBy(minimumTimeInQueueMs, TimeUnit.MILLISECONDS); subscriber.assertNoValues().assertCompleted(); }
Example #17
Source File: BottomNavigationPresenterTest.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Before public void setupBottomNavigationPresenter() { MockitoAnnotations.initMocks(this); lifecycleEvent = PublishSubject.create(); navigationEvent = PublishSubject.create(); presenter = new MainPresenter(mainView, installManager, rootInstallationRetryHandler, CrashReport.getInstance(), apkFy, contentPuller, notificationSyncScheduler, installCompletedNotifier, sharedPreferences, sharedPreferences, fragmentNavigator, deepLinkManager, true, bottomNavigationActivity, Schedulers.immediate(), Schedulers.io(), bottomNavigationNavigator, updatesManager, autoUpdateManager, permissionService, rootAvailabilityManager, appsNameExperiment, bottomNavigationMapper, accountManager, accountNavigator, agentPersistence); //simulate view lifecycle event when(mainView.getLifecycleEvent()).thenReturn(lifecycleEvent); when(bottomNavigationActivity.navigationEvent()).thenReturn(navigationEvent); }
Example #18
Source File: ListStoreAppsPresenterTest.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Test public void loadAppsAfterReachingBottomWithGenericError() { //Given an initialized ListStoreAppsPresenter with a STORE_ID and a limit of apps //When onCreate lifecycle call event happens //and the view reaches the bottom PublishSubject<Object> reachedBottomEvent = PublishSubject.create(); when(view.reachesBottom()).thenReturn(reachedBottomEvent); when(appCenter.loadNextApps(STORE_ID_TEST, LIMIT_APPS_TEST)).thenReturn( Single.just(appsModelWithGenericError)); listStoreAppsPresenter.present(); lifecycleEvent.onNext(View.LifecycleEvent.CREATE); reachedBottomEvent.onNext(null); //then should show loading verify(view).showLoading(); //and request the next apps verify(appCenter).loadNextApps(STORE_ID_TEST, LIMIT_APPS_TEST); //and show generic error verify(view).showGenericError(); }
Example #19
Source File: ThreadRepository.java From TLint with Apache License 2.0 | 6 votes |
public Observable<ThreadListData> getRecommendThreadList(final String lastTid, String lastTamp, final PublishSubject<List<Thread>> mSubject) { return mForumApi.getRecommendThreadList(lastTid, lastTamp) .doOnNext(new Action1<ThreadListData>() { @Override public void call(ThreadListData threadListData) { if (threadListData != null && threadListData.result != null) { cacheThreadList(0, TextUtils.isEmpty(lastTid), threadListData.result.data); } if (mSubject != null) { mSubject.onNext(mThreadDao.queryBuilder() .where(ThreadDao.Properties.Type.eq(Constants.TYPE_RECOMMEND)) .list()); } } }) .observeOn(AndroidSchedulers.mainThread()); }
Example #20
Source File: MapDataController.java From AirMapSDK-Android with Apache License 2.0 | 6 votes |
public MapDataController(AirMapMapView map, AirMapMapView.Configuration configuration, TemporalFilter temporalFilter){ this.map = map; this.callback = map; jurisdictionsPublishSubject = ThrottleablePublishSubject.create(); configurationPublishSubject = PublishSubject.create(); this.temporalFilter = temporalFilter; this.configuration = configuration; fetchAdvisories = true; JSONArray whitelist = AirMapConfig.getMapAllowedJurisdictions(); if(whitelist != null){ jurisdictionAllowed = new ArrayList<>(); for (int i = 0; i < whitelist.length(); i++) { jurisdictionAllowed.add(whitelist.optInt(i)); } } setupSubscriptions(configuration); }
Example #21
Source File: SuggestionViewHolder.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public SuggestionViewHolder(View itemView, PublishSubject<SearchQueryEvent> suggestionPublishSubject) { super(itemView); this.suggestionPublishSubject = suggestionPublishSubject; this.suggestionName = (TextView) itemView.findViewById(R.id.search_suggestion_app_name); this.suggestionIcon = (ImageView) itemView.findViewById(R.id.search_suggestion_app_icon); }
Example #22
Source File: AppSearchSuggestionsView.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public AppSearchSuggestionsView(FragmentView parentView, Observable<Void> toolbarClickObservable, CrashReport crashReport, String currentQuery, SuggestionCursorAdapter suggestionCursorAdapter, PublishSubject<SearchQueryEvent> queryTextChangedPublisher, Observable<MenuItem> toolbarMenuItemClick, SearchAnalytics searchAnalytics) { this.parentView = parentView; this.toolbarClickObservable = toolbarClickObservable; this.crashReport = crashReport; this.currentQuery = currentQuery; this.suggestionCursorAdapter = suggestionCursorAdapter; this.queryTextChangedPublisher = queryTextChangedPublisher; this.toolbarMenuItemClick = toolbarMenuItemClick; this.searchAnalytics = searchAnalytics; }
Example #23
Source File: ThreadRepository.java From TLint with Apache License 2.0 | 5 votes |
public Observable<List<Thread>> getThreadListObservable(final int type, PublishSubject<List<Thread>> mSubject) { Observable<List<Thread>> firstObservable = Observable.fromCallable(new Func0<List<Thread>>() { @Override public List<Thread> call() { return mThreadDao.queryBuilder().where(ThreadDao.Properties.Type.eq(type)).list(); } }); return firstObservable.concatWith(mSubject) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); }
Example #24
Source File: StoreFragment.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (bottomNavigationActivity != null) { bottomNavigationActivity.requestFocus(BOTTOM_NAVIGATION_ITEM); } final SuggestionCursorAdapter suggestionCursorAdapter = new SuggestionCursorAdapter(getContext()); if (hasSearchFromStoreFragment()) { final Toolbar toolbar = getToolbar(); final Observable<MenuItem> toolbarMenuItemClick = RxToolbar.itemClicks(toolbar) .publish() .autoConnect(); appSearchSuggestionsView = new AppSearchSuggestionsView(this, RxView.clicks(toolbar), crashReport, suggestionCursorAdapter, PublishSubject.create(), toolbarMenuItemClick, searchAnalytics); final AptoideApplication application = (AptoideApplication) getContext().getApplicationContext(); final SearchSuggestionsPresenter searchSuggestionsPresenter = new SearchSuggestionsPresenter(appSearchSuggestionsView, application.getSearchSuggestionManager(), AndroidSchedulers.mainThread(), suggestionCursorAdapter, crashReport, trendingManager, searchNavigator, false, searchAnalytics); attachPresenter(searchSuggestionsPresenter); handleOptionsItemSelected(toolbarMenuItemClick); } }
Example #25
Source File: MesosExecutorCallbackHandler.java From mantis with Apache License 2.0 | 5 votes |
private WrappedExecuteStageRequest createExecuteStageRequest(TaskInfo task) { // TODO try { return new WrappedExecuteStageRequest( PublishSubject.<Boolean>create(), mapper.readValue(task.getData().toByteArray(), ExecuteStageRequest.class)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
Example #26
Source File: PromotionAppDownloadingViewHolder.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public PromotionAppDownloadingViewHolder(View itemView, PublishSubject<PromotionAppClick> promotionAppClick) { super(itemView); this.appIcon = itemView.findViewById(R.id.app_icon); this.appName = itemView.findViewById(R.id.app_name); this.appDescription = itemView.findViewById(R.id.app_description); this.downloadProgressBar = itemView.findViewById(R.id.promotions_download_progress_bar); this.downloadProgressValue = itemView.findViewById(R.id.promotions_download_progress_number); this.pauseDownload = itemView.findViewById(R.id.promotions_download_pause_download); this.cancelDownload = itemView.findViewById(R.id.promotions_download_cancel_button); this.resumeDownload = itemView.findViewById(R.id.promotions_download_resume_download); this.downloadControlsLayout = itemView.findViewById(R.id.install_controls_layout); this.appRewardMessage = itemView.findViewById(R.id.app_reward); this.promotionAppClick = promotionAppClick; }
Example #27
Source File: TransformersTest.java From mobius with Apache License 2.0 | 5 votes |
@Test public void effectPerformerInvokesFunctionWithReceivedEffectAndEmitsReturnedEvents() { PublishSubject<String> upstream = PublishSubject.create(); TestScheduler scheduler = new TestScheduler(); Function<String, Integer> function = s -> s.length(); AssertableSubscriber<Integer> observer = upstream.compose(Transformers.fromFunction(function, scheduler)).test(); upstream.onNext("Hello"); scheduler.triggerActions(); observer.assertValue(5); }
Example #28
Source File: RxBus.java From Elephant with Apache License 2.0 | 5 votes |
/** * 注册事件源 * * @param tag * @return */ @SuppressWarnings({"rawtypes"}) public <T> Observable<T> register(@NonNull Object tag) { List<Subject> subjectList = subjectMapper.get(tag); if (null == subjectList) { subjectList = new ArrayList<Subject>(); subjectMapper.put(tag, subjectList); } Subject<T, T> subject; subjectList.add(subject = PublishSubject.create()); JLog.d("register", tag + " size:" + subjectList.size()); return subject; }
Example #29
Source File: AdsBundlesViewHolderFactory.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public AdsBundlesViewHolderFactory(PublishSubject<HomeEvent> uiEventsListener, PublishSubject<AdHomeEvent> adClickedEvents, DecimalFormat oneDecimalFormatter, String marketName, boolean showNatives) { this.uiEventsListener = uiEventsListener; this.adClickedEvents = adClickedEvents; this.oneDecimalFormatter = oneDecimalFormatter; this.marketName = marketName; this.showNatives = showNatives; }
Example #30
Source File: TopAppViewHolder.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public TopAppViewHolder(View itemView, PublishSubject<HomeEvent> appClicks, DecimalFormat oneDecimalFormatter) { super(itemView); this.appClicks = appClicks; topNumber = itemView.findViewById(R.id.top_number); appIcon = itemView.findViewById(R.id.icon); name = itemView.findViewById(R.id.name_label); downloadNumber = itemView.findViewById(R.id.download_number_label); appInfoViewHolder = new AppSecondaryInfoViewHolder(itemView, oneDecimalFormatter); TextView rating = itemView.findViewById(R.id.rating_label); rating.setTextAppearance(itemView.getContext(), R.style.Aptoide_TextView_Medium_XXS_Black); }