Search in sources :

Example 1 with GoogleApiClientException

use of com.braintreepayments.api.exceptions.GoogleApiClientException in project braintree_android by braintree.

the class BraintreeFragment method getGoogleApiClient.

protected GoogleApiClient getGoogleApiClient() {
    if (getActivity() == null) {
        postCallback(new GoogleApiClientException(ErrorType.NotAttachedToActivity, 1));
        return null;
    }
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity()).addApi(Wallet.API, new Wallet.WalletOptions.Builder().setEnvironment(GooglePayment.getEnvironment(getConfiguration().getAndroidPay())).setTheme(WalletConstants.THEME_LIGHT).build()).build();
    }
    if (!mGoogleApiClient.isConnected() && !mGoogleApiClient.isConnecting()) {
        mGoogleApiClient.registerConnectionCallbacks(new ConnectionCallbacks() {

            @Override
            public void onConnected(Bundle bundle) {
            }

            @Override
            public void onConnectionSuspended(int i) {
                postCallback(new GoogleApiClientException(ErrorType.ConnectionSuspended, i));
            }
        });
        mGoogleApiClient.registerConnectionFailedListener(new OnConnectionFailedListener() {

            @Override
            public void onConnectionFailed(ConnectionResult connectionResult) {
                postCallback(new GoogleApiClientException(ErrorType.ConnectionFailed, connectionResult.getErrorCode()));
            }
        });
        mGoogleApiClient.connect();
    }
    return mGoogleApiClient;
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) GoogleApiClientException(com.braintreepayments.api.exceptions.GoogleApiClientException) Wallet(com.google.android.gms.wallet.Wallet) Bundle(android.os.Bundle) ConnectionCallbacks(com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks) ConnectionResult(com.google.android.gms.common.ConnectionResult) OnConnectionFailedListener(com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener)

Aggregations

Bundle (android.os.Bundle)1 GoogleApiClientException (com.braintreepayments.api.exceptions.GoogleApiClientException)1 ConnectionResult (com.google.android.gms.common.ConnectionResult)1 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)1 ConnectionCallbacks (com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks)1 OnConnectionFailedListener (com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener)1 Wallet (com.google.android.gms.wallet.Wallet)1