void setListener(@Nullable RequestListener<R> listener) { synchronized (this) { Check.isNull(this.mListener); mListener = listener; } }
/** * Makes {@link RequestListener} methods to be called on the main application thread. * Default choice if neither this nor {@link #onBackgroundThread()} was called. * * @return this builder */ @Nonnull public RequestsBuilder onMainThread() { Check.isNull(mOnMainThread); mOnMainThread = true; return this; }
/** * Makes {@link RequestListener} methods to be called on a background thread. * * @return this builder */ @Nonnull public RequestsBuilder onBackgroundThread() { Check.isNull(mOnMainThread); mOnMainThread = false; return this; }
/** * @param tag tab to be used for all requests initiated by the constructed {@link * BillingRequests} * @return this builder */ @Nonnull public RequestsBuilder withTag(@Nullable Object tag) { Check.isNull(mTag); mTag = tag; return this; }
static void isNull(@Nullable Object o) { isNull(o, "Object should be null"); }
/** * Starts this {@link Checkout} and sends an initial request that checks whether billing is * supported for each product available in the Billing API. * * @param listener initial request listener */ public void start(@Nullable final Listener listener) { Check.isMainThread(); synchronized (mLock) { Check.isFalse(mState == State.STARTED, "Already started"); Check.isNull(mRequests, "Already started"); mState = State.STARTED; mBilling.onCheckoutStarted(); mRequests = mBilling.getRequests(mTag); } whenReady(listener == null ? new EmptyListener() {} : listener); }
if (mState == State.INITIAL || mState == State.DISCONNECTED || mState == State.FAILED) { Check.isNull(mService); return;