Search in sources :

Example 6 with QueuedCallback

use of com.braintreepayments.api.interfaces.QueuedCallback in project braintree_android by braintree.

the class BraintreeFragment method waitForConfiguration.

protected void waitForConfiguration(final ConfigurationListener listener) {
    fetchConfiguration();
    postOrQueueCallback(new QueuedCallback() {

        @Override
        public boolean shouldRun() {
            return getConfiguration() != null && isAdded();
        }

        @Override
        public void run() {
            listener.onConfigurationFetched(getConfiguration());
        }
    });
}
Also used : QueuedCallback(com.braintreepayments.api.interfaces.QueuedCallback)

Example 7 with QueuedCallback

use of com.braintreepayments.api.interfaces.QueuedCallback in project braintree_android by braintree.

the class BraintreeFragment method postCallback.

protected void postCallback(final List<PaymentMethodNonce> paymentMethodNonceList) {
    mCachedPaymentMethodNonces.clear();
    mCachedPaymentMethodNonces.addAll(paymentMethodNonceList);
    mHasFetchedPaymentMethodNonces = true;
    postOrQueueCallback(new QueuedCallback() {

        @Override
        public boolean shouldRun() {
            return mPaymentMethodNoncesUpdatedListener != null;
        }

        @Override
        public void run() {
            mPaymentMethodNoncesUpdatedListener.onPaymentMethodNoncesUpdated(paymentMethodNonceList);
        }
    });
}
Also used : QueuedCallback(com.braintreepayments.api.interfaces.QueuedCallback)

Aggregations

QueuedCallback (com.braintreepayments.api.interfaces.QueuedCallback)7 VisibleForTesting (android.support.annotation.VisibleForTesting)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 BraintreeException (com.braintreepayments.api.exceptions.BraintreeException)1 ConfigurationException (com.braintreepayments.api.exceptions.ConfigurationException)1 GoogleApiClientException (com.braintreepayments.api.exceptions.GoogleApiClientException)1 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)1 ConfigurationListener (com.braintreepayments.api.interfaces.ConfigurationListener)1 AndroidPayCardNonce (com.braintreepayments.api.models.AndroidPayCardNonce)1 Configuration (com.braintreepayments.api.models.Configuration)1 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 JSONException (org.json.JSONException)1