當前位置: 首頁>>代碼示例>>Java>>正文


Java Completable.create方法代碼示例

本文整理匯總了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);
            }
        }
    });
}
 
開發者ID:jorgegil96,項目名稱:JRAW-Android-Sample,代碼行數:17,代碼來源:RedditService.java

示例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);
            }
        }
    });
}
 
開發者ID:jorgegil96,項目名稱:JRAW-Android-Sample,代碼行數:21,代碼來源:RedditService.java

示例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());
                    }
                }
            });

        }
    });
}
 
開發者ID:BracketCove,項目名稱:Profiler,代碼行數:26,代碼來源:FirebaseAuthService.java

示例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());
        }
    });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:18,代碼來源:AttachmentsStore.java

示例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());
                }
            }
        }
    }));
}
 
開發者ID:sztomek,項目名稱:cleanarchitecture-unidirectional,代碼行數:17,代碼來源:AuthService.java

示例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();
    });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:28,代碼來源:KeysPersistStore.java

示例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();
    });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:8,代碼來源:KeysRamStore.java

示例8: deleteAll

import io.reactivex.Completable; //導入方法依賴的package包/類
@Override
public Completable deleteAll(int accountId) {
    return Completable.create(e -> {
        mData.remove(accountId);
        e.onComplete();
    });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:8,代碼來源:KeysRamStore.java

示例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();
    });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:32,代碼來源:FaveStore.java

示例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();
    });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:29,代碼來源:FaveStore.java

示例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());
        }
    });
}
 
開發者ID:DVT,項目名稱:showcase-android,代碼行數:16,代碼來源:RxFirebaseStorage.java

示例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));
      }
   });
}
 
開發者ID:DVT,項目名稱:showcase-android,代碼行數:20,代碼來源:RxFirebaseAuth.java

示例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();
    });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:10,代碼來源:OwnersRepositiry.java

示例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));
}
 
開發者ID:b3er,項目名稱:RxFirebase2,代碼行數:8,代碼來源:RxFirebaseDatabase.java

示例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));
}
 
開發者ID:btrautmann,項目名稱:RxFirestore,代碼行數:6,代碼來源:RxFirestoreDb.java


注:本文中的io.reactivex.Completable.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。