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;
}
Aggregations