本文整理汇总了Java中io.reactivex.processors.FlowableProcessor.onNext方法的典型用法代码示例。如果您正苦于以下问题:Java FlowableProcessor.onNext方法的具体用法?Java FlowableProcessor.onNext怎么用?Java FlowableProcessor.onNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.processors.FlowableProcessor
的用法示例。
在下文中一共展示了FlowableProcessor.onNext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: receiveDownloadEvent
import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
/**
* Receive the url download event.
* <p>
* Will receive the following event:
* {@link DownloadFlag#NORMAL}、{@link DownloadFlag#WAITING}、
* {@link DownloadFlag#STARTED}、{@link DownloadFlag#PAUSED}、
* {@link DownloadFlag#COMPLETED}、{@link DownloadFlag#FAILED};
* <p>
* Every event has {@link DownloadStatus}, you can get it and display it on the interface.
*
* @param url url
* @return DownloadEvent
*/
public FlowableProcessor<DownloadEvent> receiveDownloadEvent(String url) {
FlowableProcessor<DownloadEvent> processor = createProcessor(url, processorMap);
DownloadMission mission = missionMap.get(url);
if (mission == null) { //Not yet add this url mission.
DownloadRecord record = dataBaseHelper.readSingleRecord(url);
if (record == null) {
processor.onNext(normal(null));
} else {
File file = getFiles(record.getSaveName(), record.getSavePath())[0];
if (file.exists()) {
processor.onNext(createEvent(record.getFlag(), record.getStatus()));
} else {
processor.onNext(normal(null));
}
}
}
return processor;
}
示例2: post
import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
/**
* 触发事件
*
* @param content
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public void post(@NonNull Object tag, @NonNull Object content) {
List<FlowableProcessor> processors = mProcessorMapper.get(tag);
if (!isEmpty(processors)) {
for (FlowableProcessor processor : processors) {
processor.onNext(content);
}
}
}
示例3: flowProcessorToFlowableProcessor
import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
@Test
public void flowProcessorToFlowableProcessor() {
TestFlowProcessor<Integer> tfp = new TestFlowProcessor<>();
FlowableProcessor<Integer> fp = FlowInterop.fromFlowProcessor(tfp);
assertFalse(fp.hasSubscribers());
assertFalse(fp.hasComplete());
assertFalse(fp.hasThrowable());
assertNull(fp.getThrowable());
TestSubscriber<Integer> ts = fp.test();
assertTrue(fp.hasSubscribers());
assertFalse(fp.hasComplete());
assertFalse(fp.hasThrowable());
assertNull(fp.getThrowable());
fp.onNext(1);
fp.onNext(2);
fp.onNext(3);
fp.onNext(4);
fp.onNext(5);
fp.onComplete();
assertFalse(fp.hasSubscribers());
assertTrue(fp.hasComplete());
assertFalse(fp.hasThrowable());
assertNull(fp.getThrowable());
ts.assertResult(1, 2, 3, 4, 5);
}
示例4: flowProcessorToFlowableProcessorTake
import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
@Test
public void flowProcessorToFlowableProcessorTake() {
TestFlowProcessor<Integer> tfp = new TestFlowProcessor<>();
FlowableProcessor<Integer> fp = FlowInterop.fromFlowProcessor(tfp);
assertFalse(fp.hasSubscribers());
assertFalse(fp.hasComplete());
assertFalse(fp.hasThrowable());
assertNull(fp.getThrowable());
TestSubscriber<Integer> ts = fp.take(3).test();
assertTrue(fp.hasSubscribers());
assertFalse(fp.hasComplete());
assertFalse(fp.hasThrowable());
assertNull(fp.getThrowable());
fp.onNext(1);
fp.onNext(2);
fp.onNext(3);
assertFalse(fp.hasSubscribers());
assertFalse(fp.hasComplete());
assertFalse(fp.hasThrowable());
assertNull(fp.getThrowable());
fp.onNext(4);
fp.onNext(5);
fp.onComplete();
assertFalse(fp.hasSubscribers());
assertTrue(fp.hasComplete());
assertFalse(fp.hasThrowable());
assertNull(fp.getThrowable());
ts.assertResult(1, 2, 3);
}
示例5: flowProcessorToFlowableProcessorError
import io.reactivex.processors.FlowableProcessor; //导入方法依赖的package包/类
@Test
public void flowProcessorToFlowableProcessorError() {
TestFlowProcessor<Integer> tfp = new TestFlowProcessor<>();
FlowableProcessor<Integer> fp = FlowInterop.fromFlowProcessor(tfp);
assertFalse(fp.hasSubscribers());
assertFalse(fp.hasComplete());
assertFalse(fp.hasThrowable());
assertNull(fp.getThrowable());
TestSubscriber<Integer> ts = fp.test();
assertTrue(fp.hasSubscribers());
assertFalse(fp.hasComplete());
assertFalse(fp.hasThrowable());
assertNull(fp.getThrowable());
fp.onNext(1);
fp.onNext(2);
fp.onNext(3);
fp.onNext(4);
fp.onNext(5);
fp.onError(new IOException());
assertFalse(fp.hasSubscribers());
assertFalse(fp.hasComplete());
assertTrue(fp.hasThrowable());
assertNotNull(fp.getThrowable());
ts.assertFailure(IOException.class, 1, 2, 3, 4, 5);
}