Skip to content

Instantly share code, notes, and snippets.

View mattiaferigutti's full-sized avatar
🔨
Building What's On My Mind

Mattia Ferigutti mattiaferigutti

🔨
Building What's On My Mind
View GitHub Profile
/**
* @return true if the product has been purchased. Otherwise it returns false.
*/
private fun isPremiumUser() =
billingProcessor?.isPurchased(PRODUCT_ID) == true
override fun onBillingInitialized() {
/*
* Called when BillingProcessor was initialized and it's ready to purchase
*/
billingProcessor?.loadOwnedPurchasesFromGoogle()
billingProcessor?.purchase(this, PRODUCT_ID, "DEVELOPER PAYLOAD HERE")
private fun purchaseProduct() {
val isOneTimePurchaseSupported = billingProcessor?.isOneTimePurchaseSupported
if (isOneTimePurchaseSupported == true) {
billingProcessor?.purchase(this, PRODUCT_ID)
}
}
package com.studio.mattiaferigutti.premiumsample
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.anjlab.android.iab.v3.BillingProcessor
import com.anjlab.android.iab.v3.TransactionDetails
import kotlinx.android.synthetic.main.activity_main.*
<uses-permission android:name="com.android.vending.BILLING" />
@mattiaferigutti
mattiaferigutti / build.gradle
Last active January 17, 2021 16:46
implementations
repositories {
mavenCentral()
}
dependencies {
implementation 'com.anjlab.android.iab.v3:library:1.0.44'
}
<?xml version="1.0" encoding="utf-8"?>
<MotionScene
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@id/start"
motion:duration="1000">
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/motionLayout"
app:layoutDescription="@xml/activity_main_scene"
tools:context=".MainActivity">
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.airbnb.lottie.LottieAnimationView