本文整理汇总了Java中com.google.android.gms.tasks.Task.isSuccessful方法的典型用法代码示例。如果您正苦于以下问题:Java Task.isSuccessful方法的具体用法?Java Task.isSuccessful怎么用?Java Task.isSuccessful使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.tasks.Task
的用法示例。
在下文中一共展示了Task.isSuccessful方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onComplete
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void onComplete(@NonNull Task<Void> task) {
if (isDisposed()) return;
if (!task.isSuccessful()) {
Exception exception = task.getException();
if (terminated) {
RxJavaPlugins.onError(exception);
} else {
try {
terminated = true;
observer.onError(exception);
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
RxJavaPlugins.onError(new CompositeException(task.getException(), t));
}
}
}
}
示例2: changePassword
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public Promise<Void, BError, Void> changePassword(String email, String oldPassword, String newPassword){
final Deferred<Void, BError, Void> deferred = new DeferredObject<>();
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
OnCompleteListener<Void> resultHandler = new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
deferred.resolve(null);
} else {
deferred.reject(getFirebaseError(DatabaseError.fromException(task.getException())));
}
}
};
user.updatePassword(newPassword).addOnCompleteListener(resultHandler);
return deferred.promise();
}
示例3: then
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public Task<Void> then(@NonNull Task<Void> task) throws Exception {
if (!task.isSuccessful()) {
try {
throw task.getException();
} catch (FirebaseWebRequestException e) {
if (e.getHttpStatusCode() == 400 || e.getHttpStatusCode() == 403) {
Log.d(TAG, "Digits session deemed invalid by server");
Log.d(TAG, "Clearing legacy session");
// Permanent errors should clear the persistence key.
storageHelpers.clearDigitsSession();
}
return task;
}
}
storageHelpers.clearDigitsSession();
return task;
}
示例4: subscribe
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (!emitter.isDisposed()) {
if (!task.isSuccessful()) {
emitter.onError(task.getException());
} else {
emitter.onComplete();
}
}
}
};
reference.update(updates).addOnCompleteListener(listener);
}
示例5: onComplete
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
FirebaseAuth firebaseAuth = SessionManager.getFirebaseAuth();
FirebaseUser currentUser = SessionManager.getFirebaseUser();
boolean isEmailVerified = currentUser.isEmailVerified();
// TODO zmienić z powrotem
if (true) {
updateLoginConfigInSharedPrefs();
SessionManager.initializeCurrentUserFirebaseListeners();
SessionManager.initializeFamilyMembersFirebaseListener();
Intent intent = new Intent(context, MainActivity.class);
context.startActivity(intent);
} else {
firebaseAuth.signOut();
Toast.makeText(context, R.string.email_not_verified, Toast.LENGTH_LONG).show();
}
} else {
logger.logWarn("Sign In Failure: " + task.getException());
Toast.makeText(context, R.string.invalid_email_or_password, Toast.LENGTH_LONG).show();
}
}
示例6: listener
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
public static OnCompleteListener<Void> listener(@NonNull final CompletableEmitter emitter) {
return new OnCompleteListener<Void>() {
@Override public void onComplete(@NonNull Task<Void> task) {
if (!task.isSuccessful()) {
if (!emitter.isDisposed()) {
emitter.onError(task.getException());
}
return;
}
if (!emitter.isDisposed()) {
emitter.onComplete();
}
}
};
}
示例7: onSignInFinished
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
private void onSignInFinished(Task task) {
if (!isViewActive(view)) {
return;
}
if (task.isSuccessful()) {
//noinspection ConstantConditions
view.continueIntoApp();
} else {
Timber.w(task.getException(), "signInAnonymously:failure");
//noinspection ConstantConditions
viewModel.setShowErrorMessage(true);
viewModel.setShowContinueButton(true);
viewModel.setShowLoadingIndicator(false);
}
}
示例8: onComplete
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void onComplete(@NonNull Task<T> task) {
if (isDisposed()) return;
if (task.isSuccessful()) {
T result = task.getResult();
if (result == null) {
observer.onComplete();
} else {
observer.onSuccess(result);
}
} else {
try {
observer.onError(task.getException());
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
RxJavaPlugins.onError(new CompositeException(task.getException(), t));
}
}
}
示例9: subscribe
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override public void subscribe(final SingleEmitter<FirebaseUser> emitter) {
final OnCompleteListener<AuthResult> listener = new OnCompleteListener<AuthResult>() {
@Override public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
if (!emitter.isDisposed()) {
emitter.onError(task.getException());
}
return;
}
if (!emitter.isDisposed()) {
emitter.onSuccess(task.getResult().getUser());
}
}
};
createAuthTask(instance).addOnCompleteListener(listener);
}
示例10: subscribe
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void subscribe(final SingleEmitter<QuerySnapshot> emitter) throws Exception {
OnCompleteListener<QuerySnapshot> listener = new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (!emitter.isDisposed()) {
if (task.isSuccessful()) {
emitter.onSuccess(task.getResult());
} else {
emitter.onError(task.getException());
}
}
}
};
collectionReference.get()
.addOnCompleteListener(listener);
}
示例11: listener
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
/**
* @param emit
* @param <R>
* @return
*/
@NonNull
@CheckReturnValue
public static <R> OnCompleteListener<R> listener(@NonNull final CompletableEmitter emit) {
return new OnCompleteListener<R>() {
@Override
public void onComplete(@NonNull final Task<R> task) {
if (!emit.isDisposed()) {
if (task.isSuccessful()) {
emit.onComplete();
} else {
Exception e = task.getException();
emit.onError(e != null ? e : new RuntimeException());
}
}
}
};
}
示例12: subscribe
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
final OnCompleteListener<Void> listener = new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (!emitter.isDisposed()) {
if (!task.isSuccessful()) {
emitter.onError(task.getException());
} else {
emitter.onComplete();
}
}
}
};
reference.delete().addOnCompleteListener(listener);
}
示例13: subscribe
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {
final OnCompleteListener<DocumentReference> listener =
new OnCompleteListener<DocumentReference>() {
@Override
public void onComplete(@NonNull Task<DocumentReference> task) {
if (!emitter.isDisposed()) {
if (!task.isSuccessful()) {
emitter.onError(task.getException());
} else {
emitter.onComplete();
}
}
}
};
reference.add(value).addOnCompleteListener(listener);
}
示例14: onComplete
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
@Override
public void onComplete(@NonNull Task<Void> task) {
if (isDisposed()) return;
if (task.isSuccessful()) {
observer.onComplete();
} else {
try {
observer.onError(task.getException());
} catch (Throwable t) {
Exceptions.throwIfFatal(t);
RxJavaPlugins.onError(new CompositeException(task.getException(), t));
}
}
}
示例15: onComplete
import com.google.android.gms.tasks.Task; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onComplete(@NonNull Task<AuthResult> task)
{
if (task.isSuccessful()) {
callback.onSuccess(getCurrentUser());
} else {
callback.onFail(task.getException());
}
}