本文整理匯總了Java中io.reactivex.Completable.create方法的典型用法代碼示例。如果您正苦於以下問題:Java Completable.create方法的具體用法?Java Completable.create怎麽用?Java Completable.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.Completable
的用法示例。
在下文中一共展示了Completable.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: userlessAuthentication
import io.reactivex.Completable; //導入方法依賴的package包/類
public static Completable userlessAuthentication(
final RedditClient reddit,
final Credentials credentials) {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(CompletableEmitter e) throws Exception {
try {
OAuthData oAuthData = reddit.getOAuthHelper().easyAuth(credentials);
reddit.authenticate(oAuthData);
e.onComplete();
} catch (Exception ex) {
e.onError(ex);
}
}
});
}
示例2: userAuthentication
import io.reactivex.Completable; //導入方法依賴的package包/類
public static Completable userAuthentication(
final RedditClient reddit,
final Credentials credentials,
final String url) {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(CompletableEmitter e) throws Exception {
OAuthHelper oAuthHelper = reddit.getOAuthHelper();
try {
OAuthData oAuthData = oAuthHelper.onUserChallenge(url, credentials);
reddit.authenticate(oAuthData);
AuthenticationManager.get().onAuthenticated(oAuthData);
e.onComplete();
} catch (Exception ex) {
e.onError(ex);
}
}
});
}
示例3: deleteUser
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable deleteUser() {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(final CompletableEmitter e) throws Exception {
if (auth == null) {
auth = FirebaseAuth.getInstance();
}
final FirebaseUser user = auth.getCurrentUser();
user.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
e.onComplete();
} else {
e.onError(task.getException());
}
}
});
}
});
}
示例4: remove
import io.reactivex.Completable; //導入方法依賴的package包/類
@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());
}
});
}
示例5: signInWithEmailAndPassword
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable signInWithEmailAndPassword(final String email, final String password) {
return Completable.create(e -> auth.signInWithEmailAndPassword(email, password).addOnCompleteListener(task -> {
if (!e.isDisposed()) {
if (task.isSuccessful()) {
e.onComplete();
} else {
if (task.getException() != null) {
e.onError(task.getException());
} else {
e.onError(new UnknownError());
}
}
}
}));
}
示例6: saveKeyPair
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable saveKeyPair(@NonNull AesKeyPair pair) {
return Completable.create(e -> {
AesKeyPair alreaadyExist = findKeyPairFor(pair.getAccountId(), pair.getSessionId())
.blockingGet();
if(nonNull(alreaadyExist)){
e.onError(new DatabaseException("Key pair with the session ID is already in the database"));
return;
}
ContentValues cv = new ContentValues();
cv.put(KeyColumns.VERSION, pair.getVersion());
cv.put(KeyColumns.PEER_ID, pair.getPeerId());
cv.put(KeyColumns.SESSION_ID, pair.getSessionId());
cv.put(KeyColumns.DATE, pair.getDate());
cv.put(KeyColumns.START_SESSION_MESSAGE_ID, pair.getStartMessageId());
cv.put(KeyColumns.END_SESSION_MESSAGE_ID, pair.getEndMessageId());
cv.put(KeyColumns.OUT_KEY, pair.getMyAesKey());
cv.put(KeyColumns.IN_KEY, pair.getHisAesKey());
Uri uri = MessengerContentProvider.getKeysContentUriFor(pair.getAccountId());
getContext().getContentResolver().insert(uri, cv);
e.onComplete();
});
}
示例7: saveKeyPair
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable saveKeyPair(@NonNull AesKeyPair pair) {
return Completable.create(e -> {
prepareKeysFor(pair.getAccountId()).add(pair);
e.onComplete();
});
}
示例8: deleteAll
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable deleteAll(int accountId) {
return Completable.create(e -> {
mData.remove(accountId);
e.onComplete();
});
}
示例9: storeLinks
import io.reactivex.Completable; //導入方法依賴的package包/類
@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();
});
}
示例10: storeUsers
import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable storeUsers(int accountId, List<UserEntity> users, boolean clearBeforeStore) {
return Completable.create(e -> {
Uri uri = MessengerContentProvider.getFaveUsersContentUriFor(accountId);
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
if (clearBeforeStore) {
operations.add(ContentProviderOperation
.newDelete(uri)
.build());
}
appendUsersInsertOperation(operations, accountId, users);
for (UserEntity dbo : users) {
operations.add(ContentProviderOperation
.newInsert(uri)
.withValues(createCv(dbo))
.build());
}
if (!operations.isEmpty()) {
getContentResolver().applyBatch(MessengerContentProvider.AUTHORITY, operations);
}
e.onComplete();
});
}
示例11: delete
import io.reactivex.Completable; //導入方法依賴的package包/類
/**
* Deletes the object at this {@link StorageReference}.
*
* @param storageRef represents a reference to a Google Cloud Storage object.
* @return a {@link Completable} if the task is complete successfully.
*/
@NonNull
public static Completable delete(@NonNull final StorageReference storageRef) {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(CompletableEmitter emitter) throws Exception {
RxCompletableHandler.assignOnTask(emitter, storageRef.delete());
}
});
}
示例12: applyActionCode
import io.reactivex.Completable; //導入方法依賴的package包/類
/**
* Applies the given code, which can be any out of band code which is valid according
* to {@link FirebaseAuth#checkActionCode(String)} that does not also pass {@link FirebaseAuth#{verifyPasswordResetCode(String)},
* which requires an additional parameter.
*
* @param firebaseAuth firebaseAuth instance.
* @param code generated code by firebase.
* @return a {@link Completable} which emits when the action is completed.
*/
@NonNull
public static Completable applyActionCode(@NonNull final FirebaseAuth firebaseAuth,
@NonNull final String code) {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(CompletableEmitter emitter) throws Exception {
RxCompletableHandler.assignOnTask(emitter, firebaseAuth.applyActionCode(code));
}
});
}
示例13: storeUserDbos
import io.reactivex.Completable; //導入方法依賴的package包/類
@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();
});
}
示例14: runTransaction
import io.reactivex.Completable; //導入方法依賴的package包/類
/**
* @see DatabaseReference#runTransaction(Transaction.Handler, boolean)
*/
@NonNull @CheckResult public static Completable runTransaction(@NonNull DatabaseReference ref,
boolean fireLocalEvents, @NonNull Function<MutableData, Transaction.Result> task) {
return Completable.create(new RunTransactionOnSubscribe(ref, fireLocalEvents, task));
}
示例15: add
import io.reactivex.Completable; //導入方法依賴的package包/類
@NonNull
@CheckResult
public static <T> Completable add(@NonNull CollectionReference reference, T value) {
return Completable.create(new AddOnSubscribe<>(reference, value));
}