Search in sources :

Example 1 with AddToCartEvent

use of com.crashlytics.android.answers.AddToCartEvent in project Phonograph by kabouzeid.

the class PurchaseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_purchase);
    setDrawUnderStatusbar(true);
    ButterKnife.bind(this);
    setStatusbarColor(ACTIVITY_COLOR);
    setNavigationbarColor(ACTIVITY_COLOR);
    setTaskDescriptionColor(ACTIVITY_COLOR);
    setSupportActionBar(toolbar);
    // noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(getString(R.string.buy_pro));
    restoreButton.setEnabled(false);
    purchaseButton.setEnabled(false);
    restoreButton.setOnClickListener(v -> {
        if (restorePurchaseAsyncTask == null || restorePurchaseAsyncTask.getStatus() != AsyncTask.Status.RUNNING) {
            restorePurchase();
        }
    });
    purchaseButton.setOnClickListener(v -> {
        billingProcessor.purchase(PurchaseActivity.this, App.PRO_VERSION_PRODUCT_ID);
        if (!BuildConfig.DEBUG) {
            Answers.getInstance().logAddToCart(new AddToCartEvent().putCurrency(Currency.getInstance("EUR")).putItemId("pro_version").putItemName("Phonograph Pro").putItemPrice(BigDecimal.valueOf(3)));
        }
    });
    billingProcessor = new BillingProcessor(this, App.GOOGLE_PLAY_LICENSE_KEY, this);
    if (!BuildConfig.DEBUG) {
        Answers.getInstance().logContentView(new ContentViewEvent().putContentName("Purchase Activity").putContentId("1"));
    }
}
Also used : AddToCartEvent(com.crashlytics.android.answers.AddToCartEvent) BillingProcessor(com.anjlab.android.iab.v3.BillingProcessor) ContentViewEvent(com.crashlytics.android.answers.ContentViewEvent)

Aggregations

BillingProcessor (com.anjlab.android.iab.v3.BillingProcessor)1 AddToCartEvent (com.crashlytics.android.answers.AddToCartEvent)1 ContentViewEvent (com.crashlytics.android.answers.ContentViewEvent)1