本文整理汇总了Java中io.reactivex.Flowable.defer方法的典型用法代码示例。如果您正苦于以下问题:Java Flowable.defer方法的具体用法?Java Flowable.defer怎么用?Java Flowable.defer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Flowable
的用法示例。
在下文中一共展示了Flowable.defer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import io.reactivex.Flowable; //导入方法依赖的package包/类
private static Flowable<SqsMessage> get(AmazonSQS sqs, String queueName, Optional<String> bucketName,
Optional<AmazonS3> s3, Service service, int waitTimeSeconds) {
return Flowable.defer(() -> {
final String queueUrl = sqs.getQueueUrl(queueName).getQueueUrl();
return Flowable.just(sqs.receiveMessage(request(queueName, waitTimeSeconds)) //
.getMessages() //
.stream() //
.map(m -> Sqs.getNextMessage(m, queueUrl, bucketName, s3, sqs, service)) //
.collect(Collectors.toList())) //
.concatWith(Flowable.defer(() -> Flowable.just(sqs.receiveMessage(request(queueName, 0)) //
.getMessages() //
.stream() //
.map(m -> Sqs.getNextMessage(m, queueUrl, bucketName, s3, sqs, service)) //
.collect(Collectors.toList()))) //
.repeat())
.takeWhile(list -> !list.isEmpty()) //
.flatMapIterable(x -> x) //
.filter(opt -> opt.isPresent()).map(opt -> opt.get());
});//
}
示例2: getUsers
import io.reactivex.Flowable; //导入方法依赖的package包/类
@Override
public Flowable<List<UserEntity>> getUsers() {
return Flowable.defer(() -> Flowable.just(mUserDatabase.localUserDao().getUsers())
.map(users -> {
List<UserEntity> list = new ArrayList<>();
for (User user : users) {
list.add(this.mUserEntityMapper.mapFromLocalStorage(user));
}
return list;
}));
}
示例3: getResizedFileAsFlowable
import io.reactivex.Flowable; //导入方法依赖的package包/类
public Flowable<File> getResizedFileAsFlowable() {
return Flowable.defer(new Callable<Flowable<File>>() {
@Override
public Flowable<File> call() {
try {
return Flowable.just(getResizedFile());
} catch (IOException e) {
return Flowable.error(e);
}
}
});
}
示例4: getResizedBitmapAsFlowable
import io.reactivex.Flowable; //导入方法依赖的package包/类
public Flowable<Bitmap> getResizedBitmapAsFlowable() {
return Flowable.defer(new Callable<Flowable<Bitmap>>() {
@Override
public Flowable<Bitmap> call() {
try {
return Flowable.just(getResizedBitmap());
} catch (IOException e) {
return Flowable.error(e);
}
}
});
}
示例5: compressToFileAsFlowable
import io.reactivex.Flowable; //导入方法依赖的package包/类
public Flowable<File> compressToFileAsFlowable(final File imageFile, final String compressedFileName) {
return Flowable.defer(() -> {
try {
return Flowable.just(compressToFile(imageFile, compressedFileName));
} catch (IOException e) {
return Flowable.error(e);
}
});
}
示例6: compressToBitmapAsFlowable
import io.reactivex.Flowable; //导入方法依赖的package包/类
public Flowable<Bitmap> compressToBitmapAsFlowable(final File imageFile) {
return Flowable.defer(() -> {
try {
return Flowable.just(compressToBitmap(imageFile));
} catch (IOException e) {
return Flowable.error(e);
}
});
}
示例7: clearData
import io.reactivex.Flowable; //导入方法依赖的package包/类
public Flowable<Boolean> clearData(String tag) {
return Flowable.defer(() -> {
if (sharedPreferences != null) {
sharedPreferences.edit().remove(tag).apply();
return Flowable.just(true);
}
return Flowable.just(false);
});
}
示例8: clearAllData
import io.reactivex.Flowable; //导入方法依赖的package包/类
public Flowable<Boolean> clearAllData() {
return Flowable.defer(() -> {
if (sharedPreferences != null) {
sharedPreferences.edit().clear().apply();
return Flowable.just(true);
}
return Flowable.just(false);
});
}
示例9: getAllImages
import io.reactivex.Flowable; //导入方法依赖的package包/类
public static Flowable getAllImages(HashMap<String, Object> param) {
HashMap<String, String> map = new HashMap<>();
map.put(C.TYPE, (String) param.get(C.TYPE));
return Flowable.defer(() -> RealmHelper.getRealmItems(ImageInfo.class, map));
}
示例10: getCommentList
import io.reactivex.Flowable; //导入方法依赖的package包/类
public static Flowable getCommentList(HashMap<String, Object> param) {
HashMap<String, String> map = new HashMap<>();
map.put("article.objectId", (String) param.get(C.OBJECT_ID));
return Flowable.defer(() -> RealmHelper.getRealmItems(CommentInfo.class, map));
}
示例11: getAllUser
import io.reactivex.Flowable; //导入方法依赖的package包/类
public static Flowable getAllUser(HashMap<String, Object> param) {
return Flowable.defer(() -> RealmHelper.getRealmItems(_User.class, null));
}
示例12: getUserCommentList
import io.reactivex.Flowable; //导入方法依赖的package包/类
public static Flowable getUserCommentList(HashMap<String, Object> param) {
HashMap<String, String> map = new HashMap<>();
map.put("creater.objectId", (String) param.get(C.OBJECT_ID));
return Flowable.defer(() -> RealmHelper.getRealmItems(CommentInfo.class, map));
}
示例13: getMessageList
import io.reactivex.Flowable; //导入方法依赖的package包/类
public static Flowable getMessageList(HashMap<String, Object> param) {
HashMap<String, String> map = new HashMap<>();
map.put(C.UID, (String) param.get(C.UID));
return Flowable.defer(() -> RealmHelper.getRealmItems(MessageInfo.class, map));
}