@Override public void run() { Check.isTrue(Thread.holdsLock(mLock), "Must be synchronized"); // for each product we wait for: // 1. onReady to be called // 2. loadPurchased to be finished // 3. loadSkus to be finished mCount = ProductTypes.ALL.size() * 3; mCheckout.whenReady(this); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_history); ButterKnife.bind(this); final Adapter adapter = new Adapter(); mRecycler.setLayoutManager(new LinearLayoutManager(this)); mRecycler.setAdapter(adapter); final Billing billing = CheckoutApplication.get(this).getBilling(); mCheckout = Checkout.forActivity(this, billing); mCheckout.start(); mCheckout.whenReady(new HistoryLoader(adapter)); }
/** * 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); }