本文整理汇总了Java中io.reactivex.Observable.concat方法的典型用法代码示例。如果您正苦于以下问题:Java Observable.concat方法的具体用法?Java Observable.concat怎么用?Java Observable.concat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Observable
的用法示例。
在下文中一共展示了Observable.concat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cloneAndCheckoutUsingCache
import io.reactivex.Observable; //导入方法依赖的package包/类
public static Observable<Event> cloneAndCheckoutUsingCache(
final GitCommit gitCommit, final Path targetDirectory, final StandardCopyOption... copyOptions) {
Preconditions.checkNotNull(gitCommit);
Preconditions.checkNotNull(targetDirectory);
final Path cachePath = getCacheFolder(targetDirectory.getFileSystem())
.resolve(StringUtils.escapeStringAsFilename(gitCommit.url));
final Observable<Event> copy = Completable.fromAction(() ->
EvenMoreFiles.copyDirectory(cachePath, targetDirectory, copyOptions))
.toObservable();
return Observable.concat(
GitTasks.ensureCloneAndCheckout(gitCommit, cachePath, true), copy);
}
示例2: requestImplementation
import io.reactivex.Observable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.M)
private Observable<Permission> requestImplementation(Context context,final String... permissions) {
List<Observable<Permission>> list = new ArrayList<>(permissions.length);
List<String> unrequestedPermissions = new ArrayList<>();
// In case of multiple permissions, we create an Observable for each of them.
// At the end, the observables are combined to have a unique response.
for (String permission : permissions) {
XPermissionActivity.log("Requesting permission " + permission);
if (isGranted(context,permission)) {
// Already granted, or not Android M
// Return a granted Permission object.
list.add(Observable.just(new Permission(permission, true, false)));
continue;
}
if (isRevoked(context,permission)) {
// Revoked by a policy, return a denied Permission object.
list.add(Observable.just(new Permission(permission, false, false)));
continue;
}
PublishSubject<Permission> subject = XPermissionActivity.getSubjectByPermission(permission);
// Create a new subject if not exists
if (subject == null) {
unrequestedPermissions.add(permission);
subject = PublishSubject.create();
XPermissionActivity.setSubjectForPermission(permission, subject);
}
list.add(subject);
}
if (!unrequestedPermissions.isEmpty()) {
String[] unrequestedPermissionsArray = unrequestedPermissions.toArray(new String[unrequestedPermissions.size()]);
requestPermissionsFromActivity(context,unrequestedPermissionsArray);
}
return Observable.concat(Observable.fromIterable(list));
}
示例3: requestImplementation
import io.reactivex.Observable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.M)
private Observable<Permission> requestImplementation(final String... permissions) {
List<Observable<Permission>> list = new ArrayList<>(permissions.length);
List<String> unrequestedPermissions = new ArrayList<>();
// In case of multiple permissions, we create an Observable for each of them.
// At the end, the observables are combined to have a unique response.
for (String permission : permissions) {
Log.i("","Requesting permission " + permission);
if (isGranted(permission)) {
// Already granted, or not Android M
// Return a granted Permission object.
list.add(Observable.just(new Permission(permission, true, false)));
continue;
}
if (isRevoked(permission)) {
// Revoked by a policy, return a denied Permission object.
list.add(Observable.just(new Permission(permission, false, false)));
continue;
}
PublishSubject<Permission> subject = mRxPermissionsFragment.getSubjectByPermission(permission);
// Create a new subject if not exists
if (subject == null) {
unrequestedPermissions.add(permission);
subject = PublishSubject.create();
mRxPermissionsFragment.setSubjectForPermission(permission, subject);
}
list.add(subject);
}
if (!unrequestedPermissions.isEmpty()) {
String[] unrequestedPermissionsArray = unrequestedPermissions.toArray(new String[unrequestedPermissions.size()]);
requestPermissionsFromFragment(unrequestedPermissionsArray);
}
return Observable.concat(Observable.fromIterable(list));
}
示例4: requestImplementation
import io.reactivex.Observable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.M)
private Observable<Permission> requestImplementation(final String... permissions) {
List<Observable<Permission>> list = new ArrayList<>(permissions.length);
List<String> unrequestedPermissions = new ArrayList<>();
// In case of multiple permissions, we create an Observable for each of them.
// At the end, the observables are combined to have a unique response.
for (String permission : permissions) {
ViseLog.i("Requesting permission " + permission);
if (isGranted(permission)) {
// Already granted, or not Android M
// Return a granted Permission object.
list.add(Observable.just(new Permission(permission, true, false)));
continue;
}
if (isRevoked(permission)) {
// Revoked by a policy, return a denied Permission object.
list.add(Observable.just(new Permission(permission, false, false)));
continue;
}
PublishSubject<Permission> subject = mRxPermissionsFragment.getSubjectByPermission(permission);
// Create a new subject if not exists
if (subject == null) {
unrequestedPermissions.add(permission);
subject = PublishSubject.create();
mRxPermissionsFragment.setSubjectForPermission(permission, subject);
}
list.add(subject);
}
if (!unrequestedPermissions.isEmpty()) {
String[] unrequestedPermissionsArray = unrequestedPermissions.toArray(new String[unrequestedPermissions.size()]);
requestPermissionsFromFragment(unrequestedPermissionsArray);
}
return Observable.concat(Observable.fromIterable(list));
}
示例5: requestImplementation
import io.reactivex.Observable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.M)
private Observable<Permission> requestImplementation(final String... permissions) {
List<Observable<Permission>> list = new ArrayList<>(permissions.length);
List<String> unrequestedPermissions = new ArrayList<>();
// In case of multiple permissions, we create an Observable for each of them.
// At the end, the observables are combined to have a unique response.
for (String permission : permissions) {
mRxPermissionsFragment.log("Requesting permission " + permission);
if (isGranted(permission)) {
// Already granted, or not Android M
// Return a granted Permission object.
list.add(Observable.just(new Permission(permission, true, false)));
continue;
}
if (isRevoked(permission)) {
// Revoked by a policy, return a denied Permission object.
list.add(Observable.just(new Permission(permission, false, false)));
continue;
}
PublishSubject<Permission> subject = mRxPermissionsFragment.getSubjectByPermission(permission);
// Create a new subject if not exists
if (subject == null) {
unrequestedPermissions.add(permission);
subject = PublishSubject.create();
mRxPermissionsFragment.setSubjectForPermission(permission, subject);
}
list.add(subject);
}
if (!unrequestedPermissions.isEmpty()) {
String[] unrequestedPermissionsArray = unrequestedPermissions.toArray(new String[unrequestedPermissions.size()]);
requestPermissionsFromFragment(unrequestedPermissionsArray);
}
return Observable.concat(Observable.fromIterable(list));
}
示例6: requestImplementation
import io.reactivex.Observable; //导入方法依赖的package包/类
private Observable<Permission> requestImplementation(final String... permissions) {
List<Observable<Permission>> list = new ArrayList<>(permissions.length);
List<String> unrequestedPermissions = new ArrayList<>();
// In case of multiple permissions, we create an Observable for each of them.
// At the end, the observables are combined to have a unique response.
for (String permission : permissions) {
mRxPermissionsFragment.log("Requesting permission " + permission);
if (isGranted(permission)) {
// Already granted, or not Android M
// Return a granted Permission object.
list.add(Observable.just(new Permission(permission, true, false)));
continue;
}
if (isRevoked(permission)) {
// Revoked by a policy, return a denied Permission object.
list.add(Observable.just(new Permission(permission, false, false)));
continue;
}
PublishSubject<Permission> subject = mRxPermissionsFragment.getSubjectByPermission(permission);
// Create a new subject if not exists
if (subject == null) {
unrequestedPermissions.add(permission);
subject = PublishSubject.create();
mRxPermissionsFragment.setSubjectForPermission(permission, subject);
}
list.add(subject);
}
if (!unrequestedPermissions.isEmpty()) {
String[] unrequestedPermissionsArray = unrequestedPermissions.toArray(new String[unrequestedPermissions.size()]);
requestPermissionsFromFragment(unrequestedPermissionsArray);
}
return Observable.concat(Observable.fromIterable(list));
}
示例7: requestOnM
import io.reactivex.Observable; //导入方法依赖的package包/类
@NonNull @CheckReturnValue @TargetApi(M) Observable<Permission> requestOnM(@NonNull final String... permissions) {
final List<Observable<Permission>> list = new ArrayList<>(permissions.length);
final List<String> unrequestedPermissions = new ArrayList<>();
// In case of multiple permissions, we create an observable for each of them.
// At the end, the observables are combined to have a unique response.
for (final String permission : permissions) {
if (isGranted(permission)) {
list.add(Observable.just(Permission.granted(permission)));
} else if (isRevokedByPolicy(permission)) {
list.add(Observable.just(Permission.revokedByPolicy(permission)));
} else {
PublishSubject<Permission> subject = currentPermissionRequests.get(permission);
// Create a new subject if not exists
if (subject == null) {
unrequestedPermissions.add(permission);
subject = PublishSubject.create();
currentPermissionRequests.put(permission, subject);
}
list.add(subject);
}
}
if (!unrequestedPermissions.isEmpty()) {
final String[] permissionsToRequest = unrequestedPermissions.toArray(new String[0]);
startShadowActivity(permissionsToRequest);
}
return Observable.concat(Observable.fromIterable(list));
}
示例8: upgradeInWorkingDirectory
import io.reactivex.Observable; //导入方法依赖的package包/类
public static Observable<Event> upgradeInWorkingDirectory(final FileSystem fs) {
Preconditions.checkNotNull(fs);
return Observable.concat(
ResolveTasks.resolveDependenciesInWorkingDirectory(fs),
InstallExistingTasks.installExistingDependenciesInWorkingDirectory(fs),
Observable.just(Notification.of("Upgrade complete")));
}
示例9: downloadResolvedDependency
import io.reactivex.Observable; //导入方法依赖的package包/类
private static Observable<Event> downloadResolvedDependency(final FileSystem fs, final ResolvedDependency resolvedDependency, final Path target) {
Preconditions.checkNotNull(fs);
Preconditions.checkNotNull(resolvedDependency);
Preconditions.checkNotNull(target);
final Observable<Event> downloadSourceCode = Single.fromCallable(() -> Files.exists(target))
.flatMapObservable(exists -> {
if (exists) {
return Observable.empty();
}
return resolvedDependency.source.join(
gitCommit -> CacheTasks.cloneAndCheckoutUsingCache(gitCommit, target),
remoteArchive -> CacheTasks.downloadUsingCache(remoteArchive, target, StandardCopyOption.REPLACE_EXISTING));
});
final Path buckFilePath = fs.getPath(target.toString(), "BUCK");
final Observable<Event> downloadBuckFile = Files.exists(buckFilePath) ?
Observable.empty() :
resolvedDependency.buckResource
.map(x -> CommonTasks.downloadRemoteFile(fs, x, buckFilePath))
.orElse(Observable.empty());
final Path buckarooDepsFilePath = fs.getPath(target.toString(), "BUCKAROO_DEPS");
final Observable<Event> writeBuckarooDeps = Single.fromCallable(() ->
CommonTasks.generateBuckarooDeps(resolvedDependency.dependencies))
.flatMap(content -> CommonTasks.writeFile(
content,
buckarooDepsFilePath,
true))
.cast(Event.class)
.toObservable();
return Observable.concat(
downloadSourceCode,
downloadBuckFile,
writeBuckarooDeps.cast(Event.class));
}
示例10: installDependencyLock
import io.reactivex.Observable; //导入方法依赖的package包/类
private static Observable<Event> installDependencyLock(final Path projectDirectory, final DependencyLock lock) {
Preconditions.checkNotNull(projectDirectory);
Preconditions.checkNotNull(lock);
final Path dependencyDirectory = dependencyFolder(buckarooDirectory(projectDirectory), lock.identifier)
.toAbsolutePath();
return Observable.concat(
// Download the code and BUCK file
downloadResolvedDependency(projectDirectory.getFileSystem(), lock.origin, dependencyDirectory),
// Touch .buckconfig
CommonTasks.touchFile(dependencyDirectory.resolve(".buckconfig")).toObservable(),
// Generate .buckconfig.local
CommonTasks.writeFile(
generateBuckConfigLocal(
dependencyDirectory.resolve(".buckconfig.local"),
projectDirectory,
lock.origin.dependencies.stream()
.map(i -> i.identifier)
.collect(ImmutableList.toImmutableList())),
dependencyDirectory.resolve(".buckconfig.local"),
true).toObservable(),
// Mark the installation as complete
Observable.just(DependencyInstalledEvent.of(lock))
);
}
示例11: downloadUsingCache
import io.reactivex.Observable; //导入方法依赖的package包/类
public static Observable<Event> downloadUsingCache(final RemoteFile file, final Path target) {
Preconditions.checkNotNull(file);
Preconditions.checkNotNull(target);
final FileSystem fs = target.getFileSystem();
final Path cachePath = getCachePath(fs, file);
return Observable.concat(
downloadToCache(fs, file),
CommonTasks.copy(cachePath, target, StandardCopyOption.REPLACE_EXISTING)
.toObservable()
);
}
示例12: getMessages
import io.reactivex.Observable; //导入方法依赖的package包/类
public Observable<List<Message>> getMessages() {
final Observable<List<Message>> network = messageRepository.getMessages()
.doOnNext(messageCache::writeToCache);
final Observable<List<Message>> cache = messageCache.getMessages().filter(messages -> !messages.isEmpty());
return Observable.concat(cache, network);
}
示例13: getCredentialsForAuthenticatable
import io.reactivex.Observable; //导入方法依赖的package包/类
@Override
public Observable<AuthenticationCredentials> getCredentialsForAuthenticatable(Authenticatable authenticatable) {
return Observable.concat(
authorizationTokenDao.getCredentialsForAuthenticatable(authenticatable),
emailPasswordCredentialsDao.getCredentialsForAuthenticatable(authenticatable));
}
示例14: createAppSkeleton
import io.reactivex.Observable; //导入方法依赖的package包/类
private static Observable<Event> createAppSkeleton(final Path projectDirectory, final Project project) {
Preconditions.checkNotNull(projectDirectory);
Preconditions.checkNotNull(project);
final FileSystem fs = projectDirectory.getFileSystem();
final Identifier projectIdentifier = project.name.map(StringUtils::escapeStringGitHubStyle)
.flatMap(Identifier::parse)
.orElseGet(() -> Identifier.of("my-project"));
return Observable.concat(ImmutableList.of(
// Write the project file
CommonTasks.writeFile(
Serializers.serialize(project),
fs.getPath("buckaroo.json").toAbsolutePath(),
false)
.toObservable()
.cast(Event.class)
.onErrorReturnItem(Notification.of("buckaroo.json already exists!")),
// Touch the .buckconfig
CommonTasks.touchFile(fs.getPath(projectDirectory.toString(), ".buckconfig"))
.toObservable(),
// Generate an empty BUCKAROO_DEPS
Single.fromCallable(() -> CommonTasks.generateBuckarooDeps(ImmutableList.of()))
.flatMap(content ->
CommonTasks.writeFile(
content,
fs.getPath(projectDirectory.toString(), "BUCKAROO_DEPS"),
false))
.toObservable()
.cast(Event.class)
.onErrorReturnItem(Notification.of("BUCKAROO_DEPS already exists!")),
// Create the project directories
CommonTasks.createDirectory(fs.getPath(projectDirectory.toString(), projectIdentifier.name))
.toObservable(),
CommonTasks.createDirectory(fs.getPath(projectDirectory.toString(), projectIdentifier.name, "src"))
.toObservable(),
CommonTasks.createDirectory(fs.getPath(projectDirectory.toString(), projectIdentifier.name, "include"))
.toObservable(),
CommonTasks.createDirectory(fs.getPath(projectDirectory.toString(), projectIdentifier.name, "detail"))
.toObservable(),
// Write the Hello World cpp file
Single.fromCallable(QuickstartTasks::helloWorldCpp).flatMap(content -> CommonTasks.writeFile(
content,
fs.getPath(projectDirectory.toString(), projectIdentifier.name, "apps", "main.cpp"),
false))
.toObservable()
.cast(Event.class)
.onErrorReturnItem(Notification.of("apps/main.cpp already exists!")),
// Generate the BUCK file
Single.fromCallable(() -> Either.orThrow(BuckFile.generate(projectIdentifier)))
.flatMapObservable(content -> Observable.concat(
CommonTasks.writeFile(
content,
fs.getPath(projectDirectory.toString(), "BUCK"),
false).toObservable()
.cast(Event.class)
.onErrorReturnItem(Notification.of("BUCK-file already exists!")),
Observable.just(Notification.of("buck run :main"))
))
));
}
示例15: of
import io.reactivex.Observable; //导入方法依赖的package包/类
public static <S, T> Process<S, T> of(final Observable<S> states, final Single<T> result) {
return new Process<>(Observable.concat(
states.map(Either::left),
result.toObservable().map(Either::right)
));
}