当前位置: 首页>>代码示例>>Java>>正文


Java Observable.concat方法代码示例

本文整理汇总了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);
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:17,代码来源:CacheTasks.java

示例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));
}
 
开发者ID:paozhuanyinyu,项目名称:XPermission,代码行数:40,代码来源:XPermission.java

示例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));
}
 
开发者ID:ChangWeiBa,项目名称:AesExoPlayer,代码行数:40,代码来源:RxPermissions.java

示例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));
}
 
开发者ID:xiaoyaoyou1212,项目名称:XSnow,代码行数:40,代码来源:RxPermissions.java

示例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));
}
 
开发者ID:jiangkang,项目名称:KTools,代码行数:40,代码来源:RxPermissions.java

示例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));
}
 
开发者ID:CodyyAndroid,项目名称:RxPermissions,代码行数:39,代码来源:RxPermissions.java

示例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));
}
 
开发者ID:vanniktech,项目名称:RxPermission,代码行数:34,代码来源:RealRxPermission.java

示例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")));
    }
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:10,代码来源:UpgradeTasks.java

示例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));
    }
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:39,代码来源:InstallExistingTasks.java

示例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))
        );
    }
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:32,代码来源:InstallExistingTasks.java

示例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()
        );
    }
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:15,代码来源:CacheTasks.java

示例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);
}
 
开发者ID:charafau,项目名称:TurboChat,代码行数:9,代码来源:MessageViewModel.java

示例13: getCredentialsForAuthenticatable

import io.reactivex.Observable; //导入方法依赖的package包/类
@Override
public Observable<AuthenticationCredentials> getCredentialsForAuthenticatable(Authenticatable authenticatable) {
    return Observable.concat(
            authorizationTokenDao.getCredentialsForAuthenticatable(authenticatable),
            emailPasswordCredentialsDao.getCredentialsForAuthenticatable(authenticatable));
}
 
开发者ID:Atypon-OpenSource,项目名称:wayf-cloud,代码行数:7,代码来源:AuthenticationFacadeImpl.java

示例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"))
                ))
        ));
    }
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:72,代码来源:QuickstartTasks.java

示例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)
    ));
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:7,代码来源:Process.java


注:本文中的io.reactivex.Observable.concat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。