use of sk.henrichg.phoneprofiles.DonationFragment in project PhoneProfiles by henrichg.
the class BillingManager method startServiceConnectionIfNeeded.
private void startServiceConnectionIfNeeded(final Runnable executeOnSuccess) {
// PPApplication.logE(TAG, "startServiceConnectionIfNeeded");
if (mBillingClient.isReady()) {
if (executeOnSuccess != null) {
executeOnSuccess.run();
}
} else {
DonationFragment fragment = getFragment();
if (fragment != null)
fragment.setWaitScreen(true);
mBillingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
if (executeOnSuccess == null) {
if (getFragment() != null)
getFragment().updateGUIAfterBillingConnected();
}
if (executeOnSuccess != null) {
executeOnSuccess.run();
}
}
/*else {
Log.w(TAG, "onBillingSetupFinished() error code: " + billingResponse);
}*/
}
@Override
public void onBillingServiceDisconnected() {
// Log.w(TAG, "onBillingServiceDisconnected()");
}
});
}
}
Aggregations