org.solovyev.android.checkout.Purchase Java Examples

The following examples show how to use org.solovyev.android.checkout.Purchase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DonateActivity.java    From screenrecorder with GNU Affero General Public License v3.0 5 votes vote down vote up
private void consumePurchase(final Purchase purchase){
    mCheckout.whenReady(new Checkout.EmptyListener() {
        @Override
        public void onReady(@Nonnull BillingRequests requests) {
            requests.consume(purchase.token, new ConsumeListener());
        }
    });
}
 
Example #2
Source File: DonateDialogFragment.java    From HeartbeatFixerForGCM with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoaded(@NonNull Inventory.Products products) {
    final Inventory.Product product = products.get(ProductTypes.IN_APP);
    mAdapter.setNotifyOnChange(false);
    mAdapter.clear();

    if (product.supported) {
        for (Sku sku : product.getSkus()) {
            final Purchase purchase = product.getPurchaseInState(sku, Purchase.State.PURCHASED);
            final SkuUi skuUi = new SkuUi(sku, purchase != null);
            mAdapter.add(skuUi);
        }

        // Sort items by prices.
        mAdapter.sort(new Comparator<SkuUi>() {
            @Override
            public int compare(@NonNull SkuUi l, @NonNull SkuUi r) {
                return (int) (l.sku.detailedPrice.amount - r.sku.detailedPrice.amount);
            }
        });
        showScene(SCREEN_INVENTORY);
    } else {
        mEmptyView.setText(R.string.donate_billing_not_supported);
        showScene(SCREEN_EMPTY_VIEW);
    }

    mAdapter.notifyDataSetChanged();
}
 
Example #3
Source File: DonateDialog.java    From AcDisplay with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onLoaded(@NonNull Inventory.Products products) {
    final Inventory.Product product = products.get(ProductTypes.IN_APP);
    mAdapter.setNotifyOnChange(false);
    mAdapter.clear();

    if (product.supported) {
        for (Sku sku : product.getSkus()) {
            final Purchase purchase = product.getPurchaseInState(sku, Purchase.State.PURCHASED);
            final SkuUi skuUi = new MySkuUi(sku, purchase != null);
            mAdapter.add(skuUi);
        }

        // Sort items by prices.
        mAdapter.sort(new Comparator<SkuUi>() {
            @Override
            public int compare(@NonNull SkuUi l, @NonNull SkuUi r) {
                return (int) (l.sku.detailedPrice.amount - r.sku.detailedPrice.amount);
            }
        });

        // Show the inventory.
        refreshUi(SCREEN_INVENTORY);
    } else refreshUi(SCREEN_EMPTY_VIEW);

    mAdapter.notifyDataSetChanged();
}
 
Example #4
Source File: DonateDialog.java    From HeadsUp with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onLoaded(@NonNull Inventory.Products products) {
    final Inventory.Product product = products.get(ProductTypes.IN_APP);
    mAdapter.setNotifyOnChange(false);
    mAdapter.clear();

    if (product.supported) {
        for (Sku sku : product.getSkus()) {
            final Purchase purchase = product.getPurchaseInState(sku, Purchase.State.PURCHASED);
            final SkuUi skuUi = new SkuUi(sku, purchase != null);
            mAdapter.add(skuUi);
        }

        // Sort items by prices.
        mAdapter.sort(new Comparator<SkuUi>() {
            @Override
            public int compare(@NonNull SkuUi l, @NonNull SkuUi r) {
                return (int) (l.sku.detailedPrice.amount - r.sku.detailedPrice.amount);
            }
        });
        showScene(SCREEN_INVENTORY);
    } else {
        mEmptyView.setText(R.string.donate_billing_not_supported);
        showScene(SCREEN_EMPTY_VIEW);
    }

    mAdapter.notifyDataSetChanged();
}
 
Example #5
Source File: DonateActivity.java    From screenrecorder with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void onSuccess(Purchase purchase) {
    // here you can process the loaded purchase
    consumePurchase(purchase);
}
 
Example #6
Source File: DonateDialogFragment.java    From HeartbeatFixerForGCM with Apache License 2.0 4 votes vote down vote up
@Override
public void onSuccess(@NonNull Purchase purchase) {
    purchased();
}
 
Example #7
Source File: DonateDialog.java    From AcDisplay with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(@NonNull Purchase purchase) {
    onPurchased(false);
}
 
Example #8
Source File: DonateDialog.java    From HeadsUp with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(@NonNull Purchase purchase) {
    purchased();
}