Java 类com.google.android.gms.tasks.OnCompleteListener 实例源码

项目:BuddiesGo    文件:SignInActivity.java   
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGooogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mFirebaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(SignInActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    } else {
                        startActivity(new Intent(SignInActivity.this, MainActivity.class));
                        finish();
                    }
                }
            });
}
项目:chapp-messenger    文件:LoginActivity.java   
private void LoginVersuch() {
//  // https://firebase.google.com/docs/auth/android/password-auth
        email = et_mail.getText().toString();
        pwd = et_password.getText().toString();
        mAuth.signInWithEmailAndPassword(email, pwd)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (!task.isSuccessful()) {
                            Log.w("AndroidLoginVersuch", "signInWithEmail:failed", task.getException());
                            Toast.makeText(LoginActivity.this, "Sorry, der Login ist leider fehlgeschlagen.",
                                    Toast.LENGTH_SHORT).show();
                        } else {
                            Log.d("AndroidLoginVersuch", "signInWithEmail:onComplete:");
                            startActivity(new Intent(LoginActivity.this, MainActivity.class));
                        }
                    }
                });

    }
项目:snippets-android    文件:MainActivity.java   
private void onWriteClicked() {
    String random = UUID.randomUUID().toString();
    Map<String, Object> map = new HashMap<>();
    map.put("text", random);

    mFirestore.collection(DEFAULT_COLLECTION)
            .document()
            .set(map)
            .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    Log.d(TAG, "write:onComplete");
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "write:onComplete:failed", task.getException());
                    }
                }
            });
}
项目:shared-firebase-preferences    文件:TestActivity.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_test);

    FirebaseApp.initializeApp(this);
    FirebaseAuth.getInstance().addAuthStateListener(this);

    FirebaseAuth.getInstance().signInAnonymously()
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInAnonymously:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInAnonymously", task.getException());
                        Toast.makeText(TestActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:snippets-android    文件:MainActivity.java   
private void updateProfile() {
    // [START update_profile]
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

    UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
            .setDisplayName("Jane Q. User")
            .setPhotoUri(Uri.parse("https://example.com/jane-q-user/profile.jpg"))
            .build();

    user.updateProfile(profileUpdates)
            .addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {
                        Log.d(TAG, "User profile updated.");
                    }
                }
            });
    // [END update_profile]
}
项目:cat-is-a-dog    文件:GoogleAuthenticator.java   
/**
 * Authenticate Google user with Firebase
 * @param acct Google account
 */
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(mContext, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d(TAG, "signInWithCredential:success");
                        onSuccess();
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithCredential:failure", task.getException());
                        onFailed();
                    }
                }
            });
}
项目:urdu-font-comparator-app    文件:MainPresenter.java   
@Override
public void handleRatingUpdateAction(int fontIndex, UrduFont font) {
    if (font == null) {
        handleError(R.string.error_message_unknown_font);
    } else {
        tracker.submitFontRating(font.getName(), font.getLastRatingValue());
        databaseReference.child(String.valueOf(fontIndex))
                .setValue(font)
                .addOnCompleteListener(new OnCompleteListener<Void>() {
                    @Override
                    public void onComplete(@NonNull Task<Void> task) {
                        if (task.isSuccessful()) {
                            view.showToast(R.string.thank_you);
                        } else {
                            handleError(R.string.error_unable_to_update_rating);
                        }
                    }
                });
    }
}
项目:PiPle    文件:LoginActivity.java   
/**
 * Method createAccount
 *
 * Allows an unregistered user to create himself an account.
 *
 * @param email mail address used for his account
 * @param password password to access his account
 */
private void createAccount(String email, String password)
{
    mFirebaseAuth.createUserWithEmailAndPassword(email, password)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());

                        // If sign in fails, display a message to the user. If sign in succeeds
                        // the auth state listener will be notified and logic to handle the
                        // signed in user can be handled in the listener.
                        if (!task.isSuccessful()) {
                            Log.w(TAG, "signInWithEmail", task.getException());
                            Toast.makeText(LoginActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        } else {
                            startActivity(new Intent(LoginActivity.this, HomeActivity.class));
                            finish();
                        }
                    }
                });
}
项目:rxtasks    文件:RxTask.java   
/**
 * @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());
                }
            }
        }
    };
}
项目:snippets-android    文件:MainActivity.java   
public void shotenLongLink() {
    // [START shorten_long_link]
    Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLongLink(Uri.parse("https://abc123.app.goo.gl/?link=https://example.com/&apn=com.example.android&ibn=com.example.ios"))
            .buildShortDynamicLink()
            .addOnCompleteListener(this, new OnCompleteListener<ShortDynamicLink>() {
                @Override
                public void onComplete(@NonNull Task<ShortDynamicLink> task) {
                    if (task.isSuccessful()) {
                        // Short link created
                        Uri shortLink = task.getResult().getShortLink();
                        Uri flowchartLink = task.getResult().getPreviewLink();
                    } else {
                        // Error
                        // ...
                    }
                }
            });
    // [END shorten_long_link]
}
项目:social-app-android    文件:PostManager.java   
public void removePost(final Post post, final OnTaskCompleteListener onTaskCompleteListener) {
    final DatabaseHelper databaseHelper = ApplicationHelper.getDatabaseHelper();
    Task<Void> removeImageTask = removeImage(post.getImageTitle());

    removeImageTask.addOnSuccessListener(new OnSuccessListener<Void>() {
        @Override
        public void onSuccess(Void aVoid) {
            databaseHelper.removePost(post).addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    onTaskCompleteListener.onTaskComplete(task.isSuccessful());
                    databaseHelper.updateProfileLikeCountAfterRemovingPost(post);
                    LogUtil.logDebug(TAG, "removePost(), is success: " + task.isSuccessful());
                }
            });
            LogUtil.logDebug(TAG, "removeImage(): success");
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception exception) {
            LogUtil.logError(TAG, "removeImage()", exception);
            onTaskCompleteListener.onTaskComplete(false);
        }
    });
}
项目:android-fido    文件:U2FDemoActivity.java   
private void getSignRequest() {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS)
            == PackageManager.PERMISSION_GRANTED) {
        Log.i(TAG, "getSignRequest permission is granted");
        Task<SignRequestParams> getSignRequestTask = asyncGetSignRequest();
        getSignRequestTask.addOnCompleteListener(new OnCompleteListener<SignRequestParams>() {
            @Override
            public void onComplete(@NonNull Task<SignRequestParams> task) {
                SignRequestParams signRequest = task.getResult();
                if (signRequest == null) {
                    Log.i(TAG, "signRequest is null");
                    return;
                }
                sendSignRequestToClient(signRequest);
            }
        });
    } else {
        Log.i(TAG, "getSignRequest permission is requested");
        ActivityCompat.requestPermissions(
                this,
                new String[]{Manifest.permission.GET_ACCOUNTS},
                GET_ACCOUNTS_PERMISSIONS_REQUEST_SIGN);
    }
}
项目:Stalker    文件:AuthenticateFragment.java   
private void handleFacebookAccessToken(AccessToken token) {
    Log.d(TAG, "handleFacebookAccessToken:" + token);
    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());
    fireBaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(getActivity(), new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(getApplicationContext(), "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:GodotFireBase    文件:FacebookSignIn.java   
public void handleAccessToken(AccessToken token) {
    Utils.d("FB:Handle:AccessToken: " + token.getToken());
    // showProgressDialog();

    AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());

    mAuth.signInWithCredential(credential)
    .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {

        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            Utils.d("FB:signInWithCredential:onComplete:" + task.isSuccessful());

            // If sign in fails, display a message to the user. If sign in succeeds
            // the auth state listener will be notified and logic to handle the
            // signed in user can be handled in the listener.

            if (!task.isSuccessful()) {
                Utils.w("FB:signInWithCredential" + 
                    task.getException().toString());
            }

            // hideProgressDialog();
        }
    });
}
项目:PiPle    文件:LoginActivity.java   
/**
 * Method firebaseAuthWithGoogle
 *
 * Authenticates in Firebase through a Google Account.
 */
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mFirebaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(LoginActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                    else {
                        startActivity(new Intent(LoginActivity.this, HomeActivity.class));
                        finish();
                    }
                }
            });
}
项目:GodotFireBase    文件:TwitterSignIn.java   
private void handleTwitterSession(TwitterSession session) {
    Utils.d("Twitter:HandleSession:" + session);

    AuthCredential credential = TwitterAuthProvider.getCredential(
    session.getAuthToken().token,
    session.getAuthToken().secret);

    mAuth.signInWithCredential(credential)
    .addOnCompleteListener(activity, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if (task.isSuccessful()) {
                // Sign in success, update UI with the signed-in user's information
                Utils.d("signInWithCredential:success");
            } else {
                // If sign in fails, display a message to the user.
                Utils.w("signInWithCredential:failure: " + task.getException());
            }

            // ...
        }
    });
}
项目:DBPA    文件:Firebase.java   
protected void deletePost(Post post) {
    mPostReference.child(post.getKey().toString()).setValue(null).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Log.d(LOG_TAG, e.getLocalizedMessage());
        }
    }).addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            deleteAuthorsAndPostsCount++;
            if(deleteAuthorsAndPostsCount== ITERATIONS){
                deleteAuthorsAndPostsCount = 0;
                logEvent("Delete "+ ITERATIONS +" Authors with Posts", initialTimeDeleteAuthorsAndPosts, new Date());
                selectCount();
            }
        }
    });
    mPostReference.push();
}
项目:instagram_clone    文件:AccountActivity.java   
private void signInWithEmail(final String email, final String password) {
    mAuth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d(TAG, "signInWithEmail:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        Toast.makeText(AccountActivity.this, "Authentication successful",
                                Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(AccountActivity.this, HomeActivity.class);
                        startActivity(intent);
                        finish();
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithEmail:failure. Signing Up for new account instead.", task.getException());
                        Toast.makeText(AccountActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:rxtasks    文件:RxTaskTest.java   
@Test
public void testSingleFailure() {
    final String hello = "Hello, world!";
    when(mockHelloTask.isSuccessful())
            .thenReturn(false);
    when(mockHelloTask.getException())
            .thenReturn(new RuntimeException(hello));
    when(mockHelloTask.addOnCompleteListener(onComplete.capture()))
            .thenReturn(mockHelloTask);

    TestObserver<String> obs = TestObserver.create();
    RxTask.single(mockHelloTask).subscribe(obs);
    verify(mockHelloTask).addOnCompleteListener(onComplete.capture());
    onComplete.getValue().onComplete(mockHelloTask);
    obs.assertError(RuntimeException.class)
       .assertErrorMessage(hello)
       .dispose();

    verify(mockHelloTask).addOnCompleteListener(any(OnCompleteListener.class));
    verify(mockHelloTask).getException();
}
项目:furry-sniffle    文件:ResetPasswordActivity.java   
private void checkAccountEmailExistsInFirebase(final String email) {

        if(!validateEmail()) return;

        mProgressDialog.setTitle("Resetting Password");
        mProgressDialog.setMessage("Please wait while we send password reset email.");
        mProgressDialog.setCanceledOnTouchOutside(false);
        mProgressDialog.show();

        mFirebaseAuth = FirebaseAuth.getInstance();

        mFirebaseAuth.fetchProvidersForEmail(email).addOnCompleteListener(new OnCompleteListener<ProviderQueryResult>() {

            @Override
            public void onComplete(@NonNull Task<ProviderQueryResult> task) {
                //Log.d(TAG, "checking email exists.");
                if(task.getResult().getProviders() != null){

                            resetPassword(task.getResult().getProviders(), email);

                }
            }
        });
    }
项目:snippets-android    文件:MainActivity.java   
public void createShortLink() {
    // [START create_short_link]
    Task<ShortDynamicLink> shortLinkTask = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLink(Uri.parse("https://example.com/"))
            .setDynamicLinkDomain("abc123.app.goo.gl")
            // Set parameters
            // ...
            .buildShortDynamicLink()
            .addOnCompleteListener(this, new OnCompleteListener<ShortDynamicLink>() {
                @Override
                public void onComplete(@NonNull Task<ShortDynamicLink> task) {
                    if (task.isSuccessful()) {
                        // Short link created
                        Uri shortLink = task.getResult().getShortLink();
                        Uri flowchartLink = task.getResult().getPreviewLink();
                    } else {
                        // Error
                        // ...
                    }
                }
            });
    // [END create_short_link]
}
项目:furry-sniffle    文件:RegisterActivity.java   
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    //Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mFirebaseAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {

                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        //Log.d(TAG, "signInWithCredential:success");
                        Intent mainIntent = new Intent(RegisterActivity.this, MainActivity.class);
                        mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        mProgressDialog.dismiss();
                        startActivity(mainIntent);
                        finish();
                    } else {
                        // If sign in fails, display a message to the user.
                        //Log.w(TAG, "signInWithCredential:failure", task.getException());
                        Toast.makeText(RegisterActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:DBPA    文件:Firebase.java   
protected void updateAuthorAndYourPosts(final Author author) {
    mAuthorReference.child(author.getKey()).setValue(author).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            Log.d(LOG_TAG, e.getLocalizedMessage());
        }
    }).addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            updateAuthorCount++;
            if(updateAuthorCount== ITERATIONS){
                logEvent("Update "+ ITERATIONS +" Authors", initialTimeUpdateAuthor, new Date());
                selectCount();
            }
        }
    });
    mAuthorReference.push();
}
项目:FirebasePost    文件:RegisterActivity.java   
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d(TAG, "signInWithCredential:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        printLog(TAG, "current user :" + user.getDisplayName());
                        updateUser(user);
                        updateUi();
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithCredential:failure", task.getException());
                        Toast.makeText(RegisterActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }

                    // ...
                }
            });
}
项目:android-fido    文件:U2FDemoActivity.java   
private void updateRegisterResponseToServer(RegisterResponseData registerResponseData) {
    /* assume this operation can only happen within short time after getRegisterRequest,
       which has already checked permission
     */
    Task<String> updateRegisterResponseToServerTask =
        asyncUpdateRegisterResponseToServer(registerResponseData);
    updateRegisterResponseToServerTask.addOnCompleteListener(new OnCompleteListener<String>() {
        @Override
        public void onComplete(@NonNull Task<String> task) {
            String securityKeyToken = task.getResult();
            if (securityKeyToken == null) {
                Toast.makeText(
                    U2FDemoActivity.this,
                    "security key registration failed",
                    Toast.LENGTH_SHORT)
                    .show();
                return;
            }
            updateAndDisplayRegisteredKeys();
            Log.i(TAG, "Update register response to server with securityKeyToken: "
                + securityKeyToken);
        }
    });
}
项目:VR-One    文件:SignInActivity.java   
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCredential", task.getException());
                        Toast.makeText(SignInActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:snippets-android    文件:DocSnippets.java   
private void getMultipleDocs() {
    // [START get_multiple]
    db.collection("cities")
            .whereEqualTo("capital", true)
            .get()
            .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                @Override
                public void onComplete(@NonNull Task<QuerySnapshot> task) {
                    if (task.isSuccessful()) {
                        for (DocumentSnapshot document : task.getResult()) {
                            Log.d(TAG, document.getId() + " => " + document.getData());
                        }
                    } else {
                        Log.d(TAG, "Error getting documents: ", task.getException());
                    }
                }
            });
    // [END get_multiple]
}
项目:Profiler    文件:FirebaseDatabaseService.java   
@Override
public Completable deleteProfile(final String uid) {
    return Completable.create(
            new CompletableOnSubscribe() {
                @Override
                public void subscribe(final CompletableEmitter e) throws Exception {
                    final DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
                    rootRef.child(USER_PROFILES)
                            .child(uid)
                            .setValue(null)
                            .addOnCompleteListener(new OnCompleteListener<Void>() {
                                @Override
                                public void onComplete(@NonNull Task<Void> task) {
                                    if (task.isSuccessful()) {
                                        e.onComplete();
                                    } else {
                                        e.onError(task.getException());
                                    }
                                }
                            });
                }

            });
}
项目:android-fido    文件:U2FDemoActivity.java   
private void updateAndDisplayRegisteredKeys() {
    mProgressBar.setVisibility(View.VISIBLE);
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS)
            == PackageManager.PERMISSION_GRANTED) {
        Log.i(TAG, "updateAndDisplayRegisteredKeys permission is granted");
        Task<List<Map<String, String>>> refreshSecurityKeyTask = asyncRefreshSecurityKey();
        refreshSecurityKeyTask.addOnCompleteListener(
            new OnCompleteListener<List<Map<String, String>>>() {
                @Override
                public void onComplete(@NonNull Task<List<Map<String, String>>> task) {
                    List<Map<String, String>> tokens = task.getResult();
                    securityTokens = tokens;
                    mAdapter.clearSecurityTokens();
                    mAdapter.addSecurityToken(securityTokens);
                    displayRegisteredKeys();
                }
            });
    } else {
        Log.i(TAG, "updateAndDisplayRegisteredKeys permission is requested");
        ActivityCompat.requestPermissions(
                this,
                new String[]{Manifest.permission.GET_ACCOUNTS},
                GET_ACCOUNTS_PERMISSIONS_ALL_TOKENS);
    }
}
项目:MangoBloggerAndroidApp    文件:HomeActivity.java   
private void fetchFirebaseRemoteConfig() {
    long cacheExpiration = 36008*12; // 12 hour in seconds.
    mFirebaseRemoteConfig.fetch(cacheExpiration)
            .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {

                        // After config data is successfully fetched, it must be activated before newly fetched
                        // values are returned.
                        mFirebaseRemoteConfig.activateFetched();

                    } /*else {
                        Toast.makeText(MainActivity.this, "Fetch Failed",
                                Toast.LENGTH_SHORT).show();
                    }*/ // comment it out to test
                    getRemoteConfigs();
                }
            });
}
项目:NITKart    文件:newUser.java   
private void createAccount() {
    progressBar.setVisibility(View.VISIBLE);

    mAuth.createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
                    isRegistrationClicked = true;
                    // If sign in fails, display a message to the user. If sign in succeeds
                    // the auth state listener will be notified and logic to handle the
                    // signed in user can be handled in the listener.
                    if (!task.isSuccessful()) {
                        Toast.makeText(newUser.this, R.string.auth_failed, Toast.LENGTH_SHORT).show();
                        setViews(true);
                        isRegistrationClicked = false;
                        progressBar.setVisibility(View.GONE);
                    }
                    // ...
                }
            });
}
项目:Profiler    文件:FirebaseAuthService.java   
@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());
                    }
                }
            });

        }
    });
}
项目:Botanist    文件:AccountController.java   
/**
 * Delete a user from the database
 */
public void deleteUserFromDatabase() {
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if (user != null) {
        String userId = user.getUid();
        getDatabaseManager().deleteUserRecords(getActivity(), userId);
        user.delete().addOnCompleteListener(new OnCompleteListener<Void>() {
            /**
             * Delete the user task completed
             * @param task - the completed task
             */
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    mUser = null;
                }
            }
        });
        resetDatabaseManager();
    }
}
项目:changApp    文件:SignupActivity.java   
private void sendEmailVerification() {
    // Send verification email
    // [START send_email_verification]
    final FirebaseUser user = mAuth.getCurrentUser();
    user.sendEmailVerification()
            .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    // [START_EXCLUDE]
                    // Re-enable button

                    if (task.isSuccessful()) {
                        Toast.makeText(SignupActivity.this,
                                "Verification email sent to " + user.getEmail(),
                                Toast.LENGTH_SHORT).show();
                    } else {
                        Log.e(TAG, "sendEmailVerification", task.getException());
                        Toast.makeText(SignupActivity.this,
                                "Failed to send verification email.",
                                Toast.LENGTH_SHORT).show();
                    }
                    // [END_EXCLUDE]
                }
            });
    // [END send_email_verification]
}
项目:cda-app    文件:RegisterActivity.java   
private void sendEmailVerification() {
    firebaseAuth.getCurrentUser().sendEmailVerification()
            .addOnCompleteListener(this, new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {


                    if (task.isSuccessful()) {
                        Toast.makeText(RegisterActivity.this,
                                "Verification email sent to " + firebaseAuth.getCurrentUser().getEmail(),
                                Toast.LENGTH_SHORT).show();
                        Intent registerIntent = new Intent(RegisterActivity.this, LoginActivity.class);
                        startActivity(registerIntent);
                    } else {
                        Toast.makeText(RegisterActivity.this,
                                "Failed to send verification email.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
}
项目:Opal-Chat-AnalyticsDashboard    文件:DatabaseSourceImpl.java   
@Override
public void createMessage(
        final String uid,
        final Message message,
        final DatabaseCallback<Message> dbCallback) {
    dbReference
            .child(uid)
            .child(MESSAGES)
            .push()
            .setValue(message)
            .addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            if (task.isSuccessful()) {
                dbCallback.onSuccess(message);
            } else {
                dbCallback.onFailure(task.getException());
            }
        }
    });

}
项目:Ae4Team    文件:ChangePhoneNumberActivity.java   
private void link() {
    if (phoneNumberCheck() == true) {
        mAuth.getCurrentUser().linkWithCredential(credent)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            Log.d(TAG, "linkWithCredential:success");
                            Toast.makeText(ChangePhoneNumberActivity.this, "변경되었습니다", Toast.LENGTH_SHORT).show();
                            IntentBack();
                        } else {
                            Log.w(TAG, "linkWithCredential:failure", task.getException());
                            Toast.makeText(ChangePhoneNumberActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        }
                        // ...
                    }
                });
    } else {
        Toast.makeText(ChangePhoneNumberActivity.this, "이미 등록되어있는 번호입니다.", Toast.LENGTH_SHORT).show();
    }
}