Search in sources :

Example 1 with BillingManager

use of com.simplecity.amp_library.billing.BillingManager in project Shuttle by timusus.

the class BaseActivity method onCreate.

@CallSuper
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Permiso.getInstance().setActivity(this);
    Permiso.getInstance().requestPermissions(new Permiso.IOnPermissionResult() {

        @Override
        public void onPermissionResult(Permiso.ResultSet resultSet) {
            if (resultSet.areAllPermissionsGranted()) {
                bindService();
            } else {
                Toast.makeText(BaseActivity.this, "Permission check failed", Toast.LENGTH_LONG).show();
                finish();
            }
        }

        @Override
        public void onRationaleRequested(Permiso.IOnRationaleProvided callback, String... permissions) {
            callback.onRationaleProvided();
        }
    }, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.WAKE_LOCK);
    billingManager = new BillingManager(this, new BillingManager.BillingUpdatesListener() {

        @Override
        public void onPurchasesUpdated(List<Purchase> purchases) {
            for (Purchase purchase : purchases) {
                if (purchase.getSku().equals(Config.SKU_PREMIUM)) {
                    ShuttleApplication.getInstance().setIsUpgraded(true);
                }
            }
        }

        @Override
        public void onPremiumPurchaseCompleted() {
            ShuttleApplication.getInstance().setIsUpgraded(true);
            UpgradeDialog.getUpgradeSuccessDialog(BaseActivity.this).show();
        }

        @Override
        public void onPremiumPurchaseRestored() {
            ShuttleApplication.getInstance().setIsUpgraded(true);
            Toast.makeText(BaseActivity.this, R.string.iab_purchase_restored, Toast.LENGTH_SHORT).show();
        }
    });
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
Also used : Permiso(com.greysonparrelli.permiso.Permiso) Purchase(com.android.billingclient.api.Purchase) BillingManager(com.simplecity.amp_library.billing.BillingManager) List(java.util.List) CallSuper(android.support.annotation.CallSuper)

Aggregations

CallSuper (android.support.annotation.CallSuper)1 Purchase (com.android.billingclient.api.Purchase)1 Permiso (com.greysonparrelli.permiso.Permiso)1 BillingManager (com.simplecity.amp_library.billing.BillingManager)1 List (java.util.List)1