Java 类io.reactivex.Completable 实例源码

项目:wayf-cloud    文件:RedisDaoImpl.java   
@Override
public Completable remove(K... keys) {
    return Completable.fromAction(() -> {
        try (Jedis jedis = pool.getResource()) {
            String[] fullKeys = new String[keys.length];

            for (int i = 0; i < keys.length; i++) {
                fullKeys[i] = buildKey(keys[i]);
            }

            jedis.del(fullKeys);
        } catch (Exception e) {
            LOG.error("Could not write to Redis", e);

            throw new ServiceException(HttpStatus.SC_INTERNAL_SERVER_ERROR, e);
        }
    });
}
项目:Phoenix-for-VK    文件:RelativeshipStore.java   
@Override
public Completable storeComminities(int accountId, List<CommunityEntity> communities, int userId, boolean invalidateBefore) {
    return Completable.create(emitter -> {
        Uri uri = MessengerContentProvider.getRelativeshipContentUriFor(accountId);
        ArrayList<ContentProviderOperation> operations = new ArrayList<>(communities.size() * 2 + 1);

        if (invalidateBefore) {
            operations.add(clearOperationFor(accountId, userId, RelationshipColumns.TYPE_MEMBER));
        }

        for (CommunityEntity dbo : communities) {
            operations.add(ContentProviderOperation.newInsert(uri)
                    .withValues(RelationshipColumns.getCV(userId, -dbo.getId(), RelationshipColumns.TYPE_MEMBER))
                    .build());
        }

        OwnersRepositiry.appendCommunitiesInsertOperation(operations, accountId, communities);
        getContentResolver().applyBatch(MessengerContentProvider.AUTHORITY, operations);
        emitter.onComplete();
    });
}
项目:wayf-cloud    文件:PasswordCredentialsFacadeImpl.java   
@Override
public Completable resetPassword(Long userId, PasswordCredentials credentials) {
    AuthenticatedEntity.authenticatedAsAdmin(RequestContextAccessor.get().getAuthenticated());

    User user = new User();
    user.setId(userId);

    return FacadePolicies.singleOrException(
                authenticationFacade.getCredentialsForAuthenticatable(user)
                    .filter((userCredentials) -> PasswordCredentials.class.isAssignableFrom(userCredentials.getClass())),
                HttpStatus.SC_INTERNAL_SERVER_ERROR,
                "Could not determine user's login credentials")

            // Update the password to the new value
            .flatMap((passwordCredentials) -> {
                    // Invalidate the salt caches
                    cacheManager.evictForGroup(passwordSaltCacheGroup, ((PasswordCredentials) passwordCredentials).getEmailAddress());

                    credentials.setEmailAddress(((PasswordCredentials) passwordCredentials).getEmailAddress()); // Copy over the email address
                    user.setCredentials(credentials);

                    return authenticationFacade.revokeCredentials(user) // Revoke all existing credentials
                            .andThen(generateEmailCredentials(user)); // Create the new credentials

            }).toCompletable();
}
项目:showcase-android    文件:RxFirebaseDatabase.java   
/**
 * Set the given value on the specified {@link DatabaseReference}.
 *
 * @param ref reference represents a particular location in your database.
 * @param value value to update.
 * @return a {@link Completable} which is complete when the set value call finish successfully.
 */
@NonNull
public static Completable setValue(@NonNull final DatabaseReference ref,
                                   final Object value) {
   return Completable.create(new CompletableOnSubscribe() {
      @Override
      public void subscribe(@io.reactivex.annotations.NonNull final CompletableEmitter e) throws Exception {
         ref.setValue(value).addOnSuccessListener(new OnSuccessListener<Void>() {
            @Override public void onSuccess(Void aVoid) {
               e.onComplete();
            }
         }).addOnFailureListener(new OnFailureListener() {
            @Override public void onFailure(@NonNull Exception exception) {
               e.onError(exception);
            }
         });
      }
   });
}
项目:Phoenix-for-VK    文件:MessagesStore.java   
@Override
public Completable insertPeerDbos(int accountId, int peerId, @NonNull List<MessageEntity> dbos, boolean clearHistory) {
    return Completable.create(emitter -> {
        ArrayList<ContentProviderOperation> operations = new ArrayList<>();

        if (clearHistory) {
            Uri uri = MessengerContentProvider.getMessageContentUriFor(accountId);
            String where = MessageColumns.PEER_ID + " = ? AND " + MessageColumns.ATTACH_TO + " = ? AND " + MessageColumns.STATUS + " = ?";
            String[] args = new String[]{String.valueOf(peerId), String.valueOf(MessageColumns.DONT_ATTACH), String.valueOf(MessageStatus.SENT)};

            operations.add(ContentProviderOperation.newDelete(uri).withSelection(where, args).build());
        }

        for (MessageEntity dbo : dbos) {
            appendDboOperation(accountId, dbo, operations, null, null);
        }

        getContext().getContentResolver().applyBatch(MessengerContentProvider.AUTHORITY, operations);
        emitter.onComplete();
    });
}
项目:fluid    文件:SinkTest.java   
@Test
public void testBackPressure() {
  AtomicInteger counter = new AtomicInteger();
  Publisher<Integer> publisher = Flowable.range(0, 5000);

  Sink<Integer> slow = data -> Completable.fromAction(() -> {
    Thread.sleep(10);
    counter.incrementAndGet();
  });

  Source.fromPayloads(publisher)
    .transformFlow(f -> f
      .observeOn(Schedulers.computation()))
    .to(slow);

  await()
    .atMost(1, TimeUnit.MINUTES)
    .untilAtomic(counter, is(greaterThan(4000)));

  assertThat(counter.doubleValue()).isGreaterThan(4000.0);
}
项目:fluid    文件:SinkTest.java   
@Test
public void testForEachAsync() {
  List<Data<Integer>> list = new ArrayList<>();
  Sink<Integer> sink = Sink.forEachAsync(i -> {
    list.add(i);
    return Completable.complete();
  });
  assertThat(sink.name()).isNull();
  Completable c1 = sink.dispatch(1);
  Completable c2 = sink.dispatch(2);
  Completable c3 = sink.dispatch(3);

  assertThat(c1.blockingGet()).isNull();
  assertThat(c2.blockingGet()).isNull();
  assertThat(c3.blockingGet()).isNull();

  assertThat(list.stream().map(Data::payload).collect(Collectors.toList()))
    .containsExactly(1, 2, 3);
}
项目:pokequest    文件:PokeQuizPickImage.java   
private Completable loadImageInto(ImageView im, Pokemon pk) {
    return Completable.create(e -> picasso.load(PokeQuestApp.BASE_URL + pk.getImageUrl())
            .placeholder(R.drawable.pokeball_padding)
            .error(R.drawable.pokeball)
            .into(im, new Callback() {
                @Override
                public void onSuccess() {
                    e.onComplete();
                }

                @Override
                public void onError() {
                    e.onError(new Throwable("Error when loading poke image at id=" + pk.getId()));
                }
            }));

}
项目:PosTrainer    文件:AlarmService.java   
@Override
public Completable dismissAlarm() {
    if (mediaPlayer != null) {
        mediaPlayer.stop();
        mediaPlayer.release();
        mediaPlayer = null;
    }

    if (vibe != null) {
        vibe.cancel();
    }

    if (wakeLock != null && wakeLock.isHeld()) {
        wakeLock.release();
    }

    return Completable.complete();
}
项目:Rx2Animations    文件:RxAnimations.java   
public static Completable leave(final View view, final int xOffset, final int yOffset) {
    final float startingX = view.getX();
    final float startingY = view.getY();
    return animate(view, new AccelerateInterpolator())
            .fadeOut()
            .translateBy(xOffset, yOffset)
            .onAnimationCancel(aView -> set(aView, startingX, startingY, TRANSPARENT))
            .schedule(false);
}
项目:Phoenix-for-VK    文件:AttachmentsStore.java   
@Override
public Completable remove(int accountId, @AttachToType int attachToType, int attachToDbid, int generatedAttachmentId) {
    return Completable.create(e -> {
        Uri uri = uriForType(attachToType, accountId);

        String selection = idColumnFor(attachToType) + " = ?";
        String[] args = {String.valueOf(generatedAttachmentId)};

        int count = getContext().getContentResolver().delete(uri, selection, args);

        if (count > 0) {
            e.onComplete();
        } else {
            e.onError(new NotFoundException());
        }
    });
}
项目:gigreminder    文件:LocationRepository.java   
public Completable deleteLocation(Location location) {
    return Completable.fromAction(() -> {
        try (BriteDatabase.Transaction transaction =
                     dbHelper.getBriteDatabase().newTransaction()) {
            dbHelper.blockingDeleteByValue(entityRegistry.location.getTableName(),
                    entityRegistry.location.getIdColumn(), location.getId());
            dbHelper.blockingDeleteByValue(entityRegistry.concert.getTableName(),
                    Contract.ConcertsTable.COLUMN_LOCATION_ID, location.getId());
            dbHelper.blockingDeleteByValue(entityRegistry.syncState.getTableName(),
                    Contract.SyncStatesTable.COLUMN_LOCATION_ID, location.getId());

            transaction.markSuccessful();
        }
    })
            .subscribeOn(schedulerProvider.io());
}
项目:Phoenix-for-VK    文件:CommentsStore.java   
@Override
public Completable commitMinorUpdate(CommentUpdate update) {
    return Completable.fromAction(() -> {
        ContentValues cv = new ContentValues();

        if (update.hasLikesUpdate()) {
            cv.put(CommentsColumns.USER_LIKES, update.getLikeUpdate().isUserLikes());
            cv.put(CommentsColumns.LIKES, update.getLikeUpdate().getCount());
        }

        if (update.hasDeleteUpdate()) {
            cv.put(CommentsColumns.DELETED, update.getDeleteUpdate().isDeleted());
        }

        Uri uri = MessengerContentProvider.getCommentsContentUriFor(update.getAccountId());

        String where = CommentsColumns.SOURCE_OWNER_ID + " = ? AND " + CommentsColumns.COMMENT_ID + " = ?";
        String[] args = {String.valueOf(update.getCommented().getSourceOwnerId()), String.valueOf(update.getCommentId())};

        getContentResolver().update(uri, cv, where, args);

        minorUpdatesPublisher.onNext(update);
    });
}
项目:Reactive-Android-Programming    文件:MainActivity.java   
private void demo5() {
    Completable completable = Completable.fromAction(() -> {
        log("Let's do something");
    });

    completable.subscribe(() -> {
        log("Finished");
    }, throwable -> {
        log(throwable);
    });


    Single.just("One item")
            .subscribe((item) -> {
                log(item);
            }, (throwable) -> {
                log(throwable);
            });

    Maybe.empty();
    Maybe.just("Item")
            .subscribe(s -> {
                log("On Success: " + s);
            });

    Maybe.just("Item")
            .subscribe(s -> {
                log("On Success: " + s);
            }, throwable -> log("error"));

    Maybe.just("Item")
            .subscribe(
                    s -> log("success: " + s),
                    throwable -> log("error"),
                    () -> log("onComplete")
            );
}
项目:GitHub    文件:ShoppingCart.java   
/**
 * Adds a product to the shopping cart
 */
public Completable addProduct(Product product) {
  List<Product> updatedShoppingCart = new ArrayList<>();
  updatedShoppingCart.addAll(itemsInShoppingCart.getValue());
  updatedShoppingCart.add(product);
  itemsInShoppingCart.onNext(updatedShoppingCart);
  return Completable.complete();
}
项目:Phoenix-for-VK    文件:DocsInteractor.java   
@Override
public Completable delete(int accountId, int docId, int ownerId) {
    return networker.vkDefault(accountId)
            .docs()
            .delete(ownerId, docId)
            .flatMapCompletable(ignored -> cache.delete(accountId, docId, ownerId));
}
项目:gigreminder    文件:ArtistImportPresenterTest.java   
@Test
public void saveSelectedArtistsWhenError() throws Exception {
    when(repository.saveArtists(any())).thenReturn(Completable.error(new RuntimeException()));
    ArtistImportPresenter presenter = presenterBuilder.uiModel(twoSelectedArtistsUiModel)
            .build();

    // show error
    presenter.sendUiEvent(SaveArtistsEvent.create(twoSelectedArtistsUiModel));

    presenter.getUiModels()
            .test()
            .awaitCount(1)
            .assertNoErrors()
            .assertValue(model -> {
                assertThat(model.isSaving()).isFalse();
                assertThat(model.getSavingError().isPresent()).isTrue();
                assertThat(model.getSavingError().getValue())
                        .isEqualTo(R.string.error_saving_data);
                assertThat(model.isShouldClose()).isFalse();

                return true;
            });

    // confirm
    presenter.sendUiEvent(SaveArtistsErrorConfirmEvent.INSTANCE);

    presenter.getUiModels()
            .test()
            .awaitCount(1)
            .assertNoErrors()
            .assertValue(model -> {
                assertThat(model.getSavingError().isPresent()).isFalse();

                return true;
            });
}
项目:Phoenix-for-VK    文件:DialogsStore.java   
@Override
public Completable removePeerWithId(int accountId, int peerId) {
    return Completable.create(emitter -> {
        Uri uri = MessengerContentProvider.getDialogsContentUriFor(accountId);
        getContentResolver().delete(uri, DialogsColumns._ID + " = ?", new String[]{String.valueOf(peerId)});
        emitter.onComplete();

        dialogsDeletingPublisher.onNext(new DialogEventImpl(accountId, peerId));
    });
}
项目:Phoenix-for-VK    文件:CommentsInteractor.java   
private Completable cacheData(int accountId, @NonNull Commented commented, List<CommentEntity> data, OwnerEntities owners, boolean invalidateCache) {
    final int sourceId = commented.getSourceId();
    final int ownerId = commented.getSourceOwnerId();
    final int type = commented.getSourceType();

    return Single.just(data)
            .flatMapCompletable(dbos -> cache.comments().insert(accountId, sourceId, ownerId, type, dbos, owners, invalidateCache)
                    .toCompletable());
}
项目:PosTrainer    文件:AlarmListPresenterTest.java   
@Test
public void onAlarmSuccessfullyDeleted() {
    Mockito.when(alarmSource.deleteAlarm(ACTIVE_ALARM))
            .thenReturn(Completable.complete());

    Mockito.when(alarmManager.cancelAlarm(ACTIVE_ALARM))
            .thenReturn(Completable.complete());

    presenter.onAlarmSwiped(1, ACTIVE_ALARM);

    verify(view).showUndoSnackbar();
}
项目:async-sqs    文件:MappingSqsQueueTest.java   
public MappingSqsQueueTest() throws Exception {
    when(deserialize.apply(any())).thenReturn(DESERIALIZED_VALUE);
    when(serialize.apply(anyInt())).thenReturn(SERIALIZED_VALUE);

    when(delegateMock.publishMessage(any(), any())).thenReturn(Single.just(MESSAGE_ID));
    when(delegateMock.deleteMessage(any(String.class))).thenReturn(Completable.complete());
    when(delegateMock.receiveMessages(anyInt(), any(), any(Optional.class)))
            .thenReturn(Single.just(Collections.singletonList(STRING_MESSAGE)));
}
项目:Phoenix-for-VK    文件:MessagesInteractor.java   
@Override
public Completable deleteMessages(int accountId, Collection<Integer> ids) {
    // TODO: 07.10.2017 Remove from Cache?
    return networker.vkDefault(accountId)
            .messages()
            .delete(ids, null, null)
            .toCompletable();
}
项目:Phoenix-for-VK    文件:AudioInteractor.java   
@Override
public Completable sendBroadcast(int accountId, int audioOwnerId, int audioId, Collection<Integer> targetIds) {
    return networker.vkDefault(accountId)
            .audio()
            .setBroadcast(new IdPair(audioId, audioOwnerId), targetIds)
            .toCompletable();
}
项目:wayf-cloud    文件:DeviceAccessFacadeImpl.java   
private Completable populate(Iterable<DeviceAccess> deviceAccess, DeviceAccessQuery query) {
    // Run the inflations in parallel
    return Completable.mergeArray(
            inflatePublishers(Lists.newArrayList(deviceAccess), query),
            inflateIdentityProviders(deviceAccess, query),
            inflateDevices(deviceAccess, query)
    ).compose((completable) -> FacadePolicies.applyCompletable(completable));
}
项目:Phoenix-for-VK    文件:RealtimeMessagesProcessor.java   
private Completable findMissingChatsGetAndStore(int accountId, Collection<Integer> ids) {
    return repositories.dialogs()
            .getMissingGroupChats(accountId, ids)
            .flatMapCompletable(integers -> {
                if (integers.isEmpty()) {
                    return Completable.complete();
                }

                return networker.vkDefault(accountId)
                        .messages()
                        .getChat(null, integers, null, null)
                        .flatMapCompletable(chats -> repositories.dialogs()
                                .insertChats(accountId, chats));
            });
}
项目:Phoenix-for-VK    文件:WallsImpl.java   
@Override
public Completable delete(int accountId, int ownerId, int postId) {
    final PostUpdate update = new PostUpdate(accountId, postId, ownerId).withDeletion(true);
    return networker.vkDefault(accountId)
            .wall()
            .delete(ownerId, postId)
            .flatMapCompletable(igrored -> applyPatch(update));
}
项目:Phoenix-for-VK    文件:FaveStore.java   
@Override
public Completable storeLinks(int accountId, List<FaveLinkEntity> entities, boolean clearBefore) {
    return Completable.create(emitter -> {
        Uri uri = MessengerContentProvider.getFaveLinksContentUriFor(accountId);

        ArrayList<ContentProviderOperation> operations = new ArrayList<>();
        if (clearBefore) {
            operations.add(ContentProviderOperation
                    .newDelete(uri)
                    .build());
        }

        for (FaveLinkEntity entity : entities) {
            ContentValues cv = new ContentValues();
            cv.put(FaveLinksColumns.LINK_ID, entity.getId());
            cv.put(FaveLinksColumns.URL, entity.getUrl());
            cv.put(FaveLinksColumns.TITLE, entity.getTitle());
            cv.put(FaveLinksColumns.DESCRIPTION, entity.getDescription());
            cv.put(FaveLinksColumns.PHOTO_50, entity.getPhoto50());
            cv.put(FaveLinksColumns.PHOTO_100, entity.getPhoto100());

            operations.add(ContentProviderOperation
                    .newInsert(uri)
                    .withValues(cv)
                    .build());
        }

        getContentResolver().applyBatch(MessengerContentProvider.AUTHORITY, operations);
        emitter.onComplete();
    });
}
项目:Phoenix-for-VK    文件:OwnersRepositiry.java   
@Override
public Completable storeUserDbos(int accountId, List<UserEntity> users) {
    return Completable.create(emitter -> {
        ArrayList<ContentProviderOperation> operations = new ArrayList<>(users.size());
        appendUsersInsertOperation(operations, accountId, users);
        getContentResolver().applyBatch(MessengerContentProvider.AUTHORITY, operations);
        emitter.onComplete();
    });
}
项目:Last.fm-API    文件:LastFmUpdate.java   
public Completable  removeTagFromAlbum(String artist,String album, String tag){
    Map<String,String> options=postOptions("album.removeTag");
    options.put("artist",artist);
    options.put("album",album);
    options.put("tag",tag);
    return createService(context)
            .removeTagFromAlbum(options);
}
项目:RxPaper2    文件:RxPaperBook.java   
/**
 * Destroys all data saved in {@link Book}.
 */
public Completable destroy() {
    return Completable.fromAction(new Action() {
        @Override
        public void run() {
            book.destroy();
        }
    }).subscribeOn(scheduler);
}
项目:Phoenix-for-VK    文件:KeysPersistStore.java   
@Override
public Completable deleteAll(int accountId) {
    return Completable.create(e -> {
        Uri uri = MessengerContentProvider.getKeysContentUriFor(accountId);
        getContext().getContentResolver().delete(uri, null, null);
        e.onComplete();
    });
}
项目:fluid    文件:ScanSink.java   
@Override
public synchronized Completable dispatch(Data<OUT> data) {
  return Completable.fromAction(() -> {
    synchronized (me.escoffier.fluid.constructs.ScanSink.this) {
      current = mapper.apply(data.payload(), current);
    }
  });

}
项目:Quran    文件:BookmarkModel.java   
public Completable updateTag(final Tag tag) {
  return Completable.fromCallable(() -> {
    boolean result = bookmarksDBAdapter.updateTag(tag.id, tag.name);
    if (result) {
      tagPublishSubject.onNext(tag);
    }
    return null;
  }).subscribeOn(Schedulers.io());
}
项目:RxShell    文件:RxCmdShellTest.java   
@Before
public void setup() throws Exception {
    super.setup();
    when(builder.getProcessorFactory()).thenReturn(commandProcessorFactory);
    when(commandProcessorFactory.create()).thenReturn(cmdProcessor);
    BehaviorSubject<Boolean> idlePub = BehaviorSubject.createDefault(true);
    when(cmdProcessor.isIdle()).thenReturn(idlePub);

    when(builder.getRxShell()).thenReturn(rxShell);

    when(rxShell.open()).thenReturn(Single.create(emitter -> {
        when(rxShellSession.waitFor()).thenReturn(Single.create(e -> waitForEmitter = e));
        emitter.onSuccess(rxShellSession);
    }));

    when(rxShellSession.waitFor()).thenReturn(Single.just(0));
    when(rxShellSession.isAlive()).thenReturn(Single.just(true));
    when(rxShellSession.cancel()).thenReturn(Completable.create(e -> {
        when(rxShellSession.isAlive()).thenReturn(Single.just(false));
        waitForEmitter.onSuccess(1);
        idlePub.onNext(true);
        idlePub.onComplete();
        e.onComplete();
    }));
    when(rxShellSession.close()).thenReturn(Single.create(e -> {
        when(rxShellSession.isAlive()).thenReturn(Single.just(false));
        waitForEmitter.onSuccess(0);
        e.onSuccess(0);
        idlePub.onNext(true);
        idlePub.onComplete();
    }));
}
项目:wayf-cloud    文件:PublisherRegistrationFacadeImpl.java   
private Completable populate(PublisherRegistrationQuery query, List<PublisherRegistration> registrations) {
    if (query.getInflationPolicy() != null && query.getInflationPolicy().getChildFields().contains(PublisherRegistrationQuery.CONTACT_FIELD)) {
        Map<Long, PublisherRegistration> registrationsByContactId = new HashMap<>();

        return Observable.fromIterable(registrations)
                .filter((registration) -> registration.getContact() != null && registration.getContact().getId() != null)
                .collectInto(registrationsByContactId, (map, registration) -> map.put(registration.getContact().getId(), registration))
                .flatMapObservable((_registrationsByContactId) -> userFacade.filter(new UserQuery().ids(registrationsByContactId.keySet())))
                .flatMapCompletable((contact) -> Completable.fromAction(() -> registrationsByContactId.get(contact.getId()).setContact(contact)));
    }

    return Completable.complete();
}
项目:Android-MVVM    文件:UserRepository.java   
public LiveData<Boolean> saveUser(User user) {
    MutableLiveData<Boolean> liveData = new MutableLiveData<>();

    Completable.fromAction(() -> userDao.saveUser(user))
            .compose(transformers.applySchedulersToCompletable())
            .subscribe(() -> liveData.setValue(true), throwable -> {
                Timber.d(throwable);
                liveData.setValue(false);
            });


    return liveData;
}
项目:Phoenix-for-VK    文件:PushRegistrationResolver.java   
private Completable register(VkPushRegistration registration) {
    try {
        JSONArray fr_of_fr = new JSONArray();
        fr_of_fr.put("fr_of_fr");

        JSONObject json = new JSONObject();
        json.put("msg", "on"); // личные сообщения +
        json.put("chat", "on"); // групповые чаты +
        json.put("wall_post", "on"); // новая запись на стене пользователя +
        json.put("comment", "on"); // комментарии +
        json.put("reply", "on"); // ответы +
        json.put("wall_publish", "on"); // размещение предложенной новости +
        json.put("friend", "on");  // запрос на добавления в друзья +
        json.put("friend_accepted", "on"); // подтверждение заявки в друзья +
        json.put("group_invite", "on"); // приглашение в сообщество +
        json.put("birthday", "on"); // уведомления о днях рождениях на текущую дату

        //(хер приходят)
        json.put("like", "on"); // отметки "Мне нравится"
        json.put("group_accepted", fr_of_fr); // подтверждение заявки на вступление в группу - (хер приходят) 09.01.2016
        json.put("mention", fr_of_fr); // упоминания - (хер приходят) 09.01.2016
        json.put("repost", fr_of_fr); // действия "Рассказать друзьям" - (хер приходят) 09.01.2016

        json.put("new_post", "on"); //записи выбранных людей и сообществ;

        final String targetSettingsStr = json.toString();
        final String deviceModel = Utils.getDeviceName();
        final String osVersion = Utils.getAndroidVersion();

        return networker.vkManual(registration.getUserId(), registration.getVkToken())
                .account()
                .registerDevice(registration.getGmcToken(), deviceModel, null, registration.getDeviceId(), osVersion, targetSettingsStr)
                .toCompletable();
    } catch (JSONException e) {
        return Completable.error(e);
    }
}
项目:trust-wallet-android    文件:AddTokenInteract.java   
public Completable add(String address, String symbol, int decimals) {
    return walletRepository
            .getDefaultWallet()
            .flatMapCompletable(wallet -> tokenRepository
                    .addToken(wallet, address, symbol, decimals)
                    .observeOn(AndroidSchedulers.mainThread()));
}
项目:Phoenix-for-VK    文件:FaveInteractor.java   
@Override
public Completable addUser(int accountId, int userId) {
    return networker.vkDefault(accountId)
            .fave()
            .addUser(userId)
            .toCompletable();
}
项目:async-sqs    文件:RetryingSqsQueueTest.java   
@Test
public void testRetryUntilSuccess() {
    when(delegateMock.deleteMessage(anyString()))
            .thenThrow(TEST_EXCEPTION)
            .thenReturn(Completable.complete());

    retryingQueue.deleteMessage(RECEIPT_HANDLE);
    verify(delegateMock, times(2)).deleteMessage(RECEIPT_HANDLE);
    assertThat(RETRY_COUNT).isGreaterThanOrEqualTo(2);
}