Java 类com.google.android.gms.common.api.OptionalPendingResult 实例源码

项目:VR-One    文件:SignInActivity.java   
@Override
public void onStart(){
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);

    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:CSI-KJSCEOfficial    文件:LoginActivity.java   
@Override
protected void onStart() {
    super.onStart();
    OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if(pendingResult.isDone()){
        Log.d(TAG,"onStart(): Cached sign in");
        GoogleSignInResult result = pendingResult.get();
        handleSignInResult(result);
    } else {
        showProgressDialog();
        pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:WaJeun    文件:MainActivity.java   
@Override
public void onStart() {
    super.onStart();
    mAuth.addAuthStateListener(mAuthListener);

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.

        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {

                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:igrow-android    文件:SignInActivity.java   
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:SHIKSHAK    文件:LoginActivity.java   
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:wisebite_android    文件:LoginActivity.java   
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:Android-nRF-Beacon-for-Eddystone    文件:UpdateFragment.java   
private void handleSilentSignIn(){

        OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);

        if (pendingResult.isDone()) {
            // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
            // and the GoogleSignInResult will be available instantly.
            Log.d(Utils.TAG, "Got cached sign-in");
            GoogleSignInResult result = pendingResult.get();
            handleSignInResult(result);
        } else {
            pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
                @Override
                public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                    handleSignInResult(googleSignInResult);
                }
            });
        }
    }
项目:travelers-diary    文件:LoginActivity.java   
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        GoogleSignInResult result = opr.get();
        handleGoogleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        mAuthProgressDialog.show();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                handleGoogleSignInResult(googleSignInResult);
            }
        });
    }

    mFirebaseRef.addAuthStateListener(mAuthStateListener);
}
项目:TrinityLocker    文件:AuthManager.java   
public void onStart() {
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        AppLogger.debug("Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:Focus-Android-App    文件:LoginActivity.java   
@Override
public void onResume() {
    super.onResume();
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:Focus-Android-App    文件:LoginActivity.java   
@Override
protected void onStart() {
    super.onStart();
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:Focus-Android-App    文件:LoginActivity.java   
public void SingInIntent() {
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:BeAuthentic    文件:GoogleStrategy.java   
@Override
public Bundle confirmCredential(AccountAuthenticatorResponse response, Account account, Bundle data) {
    final Bundle bundle = new Bundle();
    if (TextUtils.isEmpty(data.getString(AccountManager.KEY_AUTHTOKEN))) {
        final OptionalPendingResult<GoogleSignInResult> pendingResult = GoogleApiAdapter.getInstance().performSilentSignIn();
        if (pendingResult != null) {
            final GoogleSignInResult googleSignInResult = pendingResult.get();
            if (googleSignInResult != null) {
                final GoogleSignInAccount signInAccount = googleSignInResult.getSignInAccount();
                if (signInAccount != null) {
                    bundle.putString(AccountManager.KEY_AUTHTOKEN, signInAccount.getIdToken());
                    bundle.putString(AccountManager.KEY_ACCOUNT_NAME, signInAccount.getDisplayName());
                }
            }
        }
    } else {
        bundle.putString(AccountManager.KEY_AUTHTOKEN, data.getString(AccountManager.KEY_AUTHTOKEN));
    }
    bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
    bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, AuthenticAuthenticator.ACCOUNT_TYPE);
    bundle.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, !TextUtils.isEmpty(bundle.getString(AccountManager.KEY_AUTHTOKEN)));
    return bundle;
}
项目:googleplayAPI    文件:SignInActivity.java   
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:travelers-diary    文件:LoginActivity.java   
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        GoogleSignInResult result = opr.get();
        handleGoogleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        mAuthProgressDialog.show();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                handleGoogleSignInResult(googleSignInResult);
            }
        });
    }

    mFirebaseRef.addAuthStateListener(mAuthStateListener);
}
项目:friendspell    文件:MainActivity.java   
@Override
public void onConnected(Bundle connectionHint) {
  Timber.d("onConnected");
  if (shouldAutoLogin) {
    OptionalPendingResult<GoogleSignInResult> pendingResult =
            googleApiClientBridge.silentSignIn(googleApiClientToken);
    if (pendingResult.isDone()) {
      // There's immediate result available.
      handleSignInResult(pendingResult.get());
    } else {
      // There's no immediate result ready
      pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
        @Override
        public void onResult(@NonNull GoogleSignInResult result) {
          handleSignInResult(result);
        }
      });
    }
  }
}
项目:social-api    文件:GoogleService.java   
@Override
public void onStart() {
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Config.debug(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);

    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        Config.debug(TAG, "New sign-in");
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:Picoroid    文件:gSignIn.java   
@Override
public void onStart() {
    super.onStart();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:the-blue-alliance-android    文件:GoogleAuthProvider.java   
@WorkerThread
public Observable<GoogleSignInUser> signInLegacyUser() {
    if (mGoogleApiClient == null) {
        TbaLogger.i("Lazy loading Google API Client for legacy sign in");
        loadGoogleApiClient();
    }
    if (mGoogleApiClient == null) {
        TbaLogger.i("Unable to get API Client for legacy sign in");
        return Observable.empty();
    }
    onStart();
    OptionalPendingResult<GoogleSignInResult> optionalResult = Auth.GoogleSignInApi
            .silentSignIn(mGoogleApiClient);
    GoogleSignInResult result = optionalResult.await();
    onStop();
    if (result.isSuccess()) {
        return Observable.just(new GoogleSignInUser(result.getSignInAccount()));
    } else {
        TbaLogger.w("Unable to complete legacy sign in: " + result.getStatus().getStatusMessage());
    }
    return Observable.empty();
}
项目:triples    文件:BaseTriplesActivity.java   
@Override
public void onStart() {
  super.onStart();

  OptionalPendingResult<GoogleSignInResult> opr =
      Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
  if (opr.isDone()) {
    // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
    // and the GoogleSignInResult will be available instantly.
    Log.d(TAG, "Got cached sign-in. isConnected: " + mGoogleApiClient.isConnected());
    GoogleSignInResult result = opr.get();
    handleSignInResult(result);
  } else {
    // If the user has not previously signed in on this device or the sign-in has expired,
    // this asynchronous branch will attempt to sign in the user silently.  Cross-device
    // single sign-on will occur in this branch.
    opr.setResultCallback(
        new ResultCallback<GoogleSignInResult>() {
          @Override
          public void onResult(GoogleSignInResult googleSignInResult) {
            handleSignInResult(googleSignInResult);
          }
        });
  }
}
项目:YourAppIdea    文件:GoogleAuthDelegate.java   
public void onStart() {
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        if (BuildConfig.DEBUG) {
            Log.d(MCXApplication.LOG_TAG, "Got cached sign-in");
        }
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        //showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                //hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:Botanist    文件:AccountActivity.java   
@Override
public void onStart() {
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently. Cross-device
        // single sign-on will occur in this branch.
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            /**
             * Try to sign in the user silently
             * @param googleSignInResult - the sign in attempt result
             */
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                handleSignInResult(googleSignInResult);
            }
        });
    }
    mAuth.addAuthStateListener(mAuthListener);
    mController.load();
    mController.showTutorial(false);
    super.onStart();
}
项目:Botanist    文件:LoginActivity.java   
/**
 * The app launched
 */
@Override
public void onStart() {
    super.onStart();
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    }
    else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently. Cross-device
        // single sign-on will occur in this branch.
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            /**
             * Silently sign the user back in
             * @param googleSignInResult - result of the signin attempt
             */
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                handleSignInResult(googleSignInResult);
            }
        });
    }
    mAuth.addAuthStateListener(mAuthListener);
}
项目:RxGooglePhotos    文件:GoogleSilentSignInOnSubscribe.java   
@Override
protected void act() {
    OptionalPendingResult<GoogleSignInResult> result = Auth.GoogleSignInApi.silentSignIn(googleApiClient);
    if (result.isDone()) {
        handleSignInResult(result.get());
    } else {
        result.setResultCallback(this::handleSignInResult);
    }
}
项目:scab    文件:InfoFromGoogleActivity.java   
@Override
public void onStart() {
    super.onStart();

    // Reset this - maybe the user has gone to another app to turn on wifi / network.
    this.triedOnce = false;

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:RxSocialAuth    文件:RxGoogleAuthFragment.java   
private void silentSignIn() {
    OptionalPendingResult<GoogleSignInResult> pendingResult =
            Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);

    if (pendingResult.isDone()) {
        handleSignInResult(pendingResult.get());
    } else {
        pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                handleSignInResult(googleSignInResult);
            }
        });
    }
}
项目:event-app    文件:login.java   
/**
 * Called when the Fragment is visible to the user.
 * This is generally tied to Activity.onStart of the containing Activity's lifecycle.
 * */
@Override
public void onStart() {
    super.onStart();

    //connects client to google play services
    //if(mGoogleApiClient != null)
    //    mGoogleApiClient.connect();

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if(opr.isDone()) {
        // if the users cached creds are still valid, OptionalPendingResult will be done and sign in
        // is available instantly
        Log.d(TAG,"Got cached sign in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } /*else {
        // if the user has not previously signed in on this device, or the sign-in has expired
        // this async branch with attempt to sign in the user silently
        // cross device single sign-on will occur in this branch
        showProgressDialog();
        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
                hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }*/
}
项目:SmartLockSample    文件:LoginActivity.java   
private void processRetrievedCredential(Credential credential) {
    String accountType = credential.getAccountType();
    if(accountType == null) {
        if (Util.isValidCredential(credential)) {
            goToContent();
        } else {
            // This is likely due to the credential being changed outside of
            // Smart Lock,
            // ie: away from Android or Chrome. The credential should be deleted
            // and the user allowed to enter a valid credential.
            Log.d(TAG, "Retrieved credential invalid, so delete retrieved" +
                    " credential.");
            Toast.makeText(this, "Retrieved credentials are invalid, so will be deleted.", Toast.LENGTH_LONG).show();
            deleteCredential(credential);
            requestCredentials();
            mSignInButton.setEnabled(false);
        }
    }
    else if (accountType.equals(IdentityProviders.GOOGLE)) {
        // The user has previously signed in with Google Sign-In. Silently
        // sign in the user with the same ID.
        // See https://developers.google.com/identity/sign-in/android/
        GoogleSignInOptions gso =
                new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                        .requestEmail()
                        .build();
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this, this)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .setAccountName(credential.getId())
                .build();
        OptionalPendingResult<GoogleSignInResult> opr =
                Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
        // ...
    }
}
项目:SocialSignIn_Demo    文件:GooglePlusLoginHelper.java   
public void connectWithGPlus()
{
    /*if(!mGoogleApiClient.isConnecting()){
        mShouldResolve = true;
        mGoogleApiClient.connect();
    }*/

    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (opr.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        Log.d(TAG, "Got cached sign-in");
        GoogleSignInResult result = opr.get();
        handleSignInResult(result);
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.

        opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(GoogleSignInResult googleSignInResult) {
        //      hideProgressDialog();
                handleSignInResult(googleSignInResult);
            }
        });
    }

}
项目:Tasking    文件:MainActivity.java   
@Override
public void onConnected(@Nullable Bundle bundle) {
    if (wantToSignOut) {
        signOut();
    } else {
        // Connected to update user images
        OptionalPendingResult<GoogleSignInResult> optionalPendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);

        optionalPendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult googleSignInResult) {
                if (wantToLoadUserImages) {
                    if (googleSignInResult.isSuccess()) {
                        GoogleSignInAccount acct = googleSignInResult.getSignInAccount();

                        if (acct != null && acct.getPhotoUrl() != null && !acct.getPhotoUrl().toString().isEmpty()) {
                            downloadUserImage(acct.getPhotoUrl(), getString(R.string.user_image));
                        }
                    }

                    getUserCoverImageUrl();
                    wantToLoadUserImages = false;
                }
            }
        });
    }
}
项目:friendspell    文件:MainActivityTest.java   
protected static void setupGoogleApiClientBridge(
    GoogleApiClientBridge googleApiClientBridge, final boolean initialStatus) {
  final String token = "token";
  final ArgumentCaptor<GoogleApiClient.ConnectionCallbacks> connectedArgument
      = ArgumentCaptor.forClass(GoogleApiClient.ConnectionCallbacks.class);
  final ArgumentCaptor<GoogleApiClient.OnConnectionFailedListener> failedArgument
      = ArgumentCaptor.forClass(GoogleApiClient.OnConnectionFailedListener.class);
  Mockito.when(googleApiClientBridge.init(Mockito.any(Activity.class),
      connectedArgument.capture(), failedArgument.capture())).thenReturn(token);
  Mockito.doAnswer(new Answer() {
    @Override public Object answer(InvocationOnMock invocation) throws Throwable {
        connectedArgument.getValue().onConnected(null);
        return null;
    }
  }).when(googleApiClientBridge).connect(Mockito.anyString());

  GoogleSignInAccount account = Mockito.mock(GoogleSignInAccount.class);
  Mockito.when(googleApiClientBridge.getCurrentAccount()).thenReturn(account);

  @SuppressWarnings("unchecked") OptionalPendingResult<GoogleSignInResult> mockPendingResult =
          Mockito.mock(OptionalPendingResult.class);
  GoogleSignInResult mockInitialSignInResult = Mockito.mock(GoogleSignInResult.class);
  Mockito.when(mockInitialSignInResult.isSuccess()).thenReturn(initialStatus);
  Mockito.when(mockInitialSignInResult.getSignInAccount()).thenReturn(account);
  GoogleSignInResult mockSuccessfulSignInResult = Mockito.mock(GoogleSignInResult.class);
  Mockito.when(mockSuccessfulSignInResult.isSuccess()).thenReturn(true);
  Mockito.when(mockSuccessfulSignInResult.getSignInAccount()).thenReturn(account);
  Mockito.when(mockPendingResult.isDone()).thenReturn(true);
  Mockito.when(mockPendingResult.get()).thenReturn(mockInitialSignInResult);
  Mockito.when(googleApiClientBridge.silentSignIn(Mockito.anyString()))
      .thenReturn(mockPendingResult);
  Mockito.when(googleApiClientBridge.isConnected(Mockito.anyString())).thenReturn(true);
  Mockito.when(googleApiClientBridge.isSignedIn()).thenReturn(initialStatus);
  Mockito.when(googleApiClientBridge
      .getSignInResultFromIntent(ArgumentMatchers.isNull(Intent.class)))
      .thenReturn(mockSuccessfulSignInResult);
  Mockito.when(googleApiClientBridge.getSignInIntent(Mockito.anyString()))
      .thenReturn(new Intent("com.google.android.gms.auth.GOOGLE_SIGN_IN"));
}
项目:easygoogle    文件:SignIn.java   
/**
 * Get the currently signed in user as a GoogleSignInAccount.
 * @return a {@link GoogleSignInAccount} or null.
 */
public GoogleSignInAccount getCurrentUser() {
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(
            getFragment().getGoogleApiClient());
    if (opr.isDone()) {
        return opr.get().getSignInAccount();
    } else {
        return null;
    }
}
项目:androidApp    文件:GoogleAccountLoader.java   
@Override
public void load(final CredentialsListener listener) {

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestIdToken(TranSappApplication.getAppContext().getString(R.string.server_client_id))
            .build();
    final GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(TranSappApplication.getAppContext())
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    mGoogleApiClient.registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
        @Override
        public void onConnected(@Nullable Bundle bundle) {
            OptionalPendingResult<GoogleSignInResult> pendingResult =
                    Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
            if (pendingResult.isDone()) {
                loadDataFromSignInResult(pendingResult.get(), listener, mGoogleApiClient);
            } else {
                pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
                    @Override
                    public void onResult(@NonNull GoogleSignInResult result) {
                        if (result.isSuccess()) {
                            loadDataFromSignInResult(result, listener, mGoogleApiClient);
                        } else {
                            listener.onError(new ServerStatusCode(LOGIN_API_ERROR));
                        }
                    }
                }, 5000, TimeUnit.MILLISECONDS);
            }
        }

        @Override
        public void onConnectionSuspended(int i) {
            listener.onError(new ServerStatusCode(LOGIN_API_ERROR));
        }
    });
    mGoogleApiClient.connect();

}
项目:QuickPush    文件:LoginManager.java   
public GoogleSignInResult cacheSignIn(GoogleApiClient client){
    OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(client);
    if(opr.isDone()) {
        Log.d(TAG, "LoginManager::cacheSignIn - Got cache sign-in");
        GoogleSignInResult result = opr.get();
        mAccount = result.getSignInAccount();
        return result;
    }
    return null;
}
项目:android-fido    文件:U2FDemoActivity.java   
/**
 * Show SignIn button to request user sign in or display all registered security tokens
 */
private void updateUI() {
    // We check a boolean value in SharedPreferences to determine whether the user has been
    // signed in. This value is false by default. It would be set to true after signing in and
    // would be reset to false after user clicks "Sign out".
    // After the users clicks "Sign out", we couldn't use
    // GoogleSignInApi#silentSignIn(GoogleApiClient), because it silently signs in the user
    // again. Thus, we rely on this boolean value in SharedPreferences.
    if (!getAccountSignInStatus()) {
        displayAccountNotSignedIn();
        return;
    }

    OptionalPendingResult<GoogleSignInResult> pendingResult =
        Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
    if (pendingResult.isDone()) {
        // If the user's cached credentials are valid, the OptionalPendingResult will be "done"
        // and the GoogleSignInResult will be available instantly.
        if (pendingResult.get().isSuccess()) {
            mGoogleSignInAccount = pendingResult.get().getSignInAccount();
            displayAccountSignedIn(pendingResult.get().getSignInAccount().getEmail(),
                pendingResult.get().getSignInAccount().getDisplayName());
        } else {
            displayAccountNotSignedIn();
        }
    } else {
        // If the user has not previously signed in on this device or the sign-in has expired,
        // this asynchronous branch will attempt to sign in the user silently.  Cross-device
        // single sign-on will occur in this branch.
        displayAccountNotSignedIn();

        pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
            @Override
            public void onResult(@NonNull GoogleSignInResult result) {
                if (result.isSuccess()) {
                    mGoogleSignInAccount = result.getSignInAccount();
                    displayAccountSignedIn(result.getSignInAccount().getEmail(),
                        result.getSignInAccount().getDisplayName());
                } else {
                    displayAccountNotSignedIn();
                }
            }
        });
    }
}
项目:BeAuthentic    文件:GoogleApiAdapter.java   
public OptionalPendingResult<GoogleSignInResult> performSilentSignIn() {
    return Auth.GoogleSignInApi.silentSignIn(client);
}
项目:friendspell    文件:GoogleApiClientBridge.java   
public OptionalPendingResult<GoogleSignInResult> silentSignIn(String token) {
  GoogleApiClient googleApiClient = clients.get(token);
  return Auth.GoogleSignInApi.silentSignIn(googleApiClient);
}