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);
}
Aggregations