Search in sources :

Example 1 with DonationFragment

use of sk.henrichg.phoneprofilesplus.DonationFragment in project PhoneProfilesPlus 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(@BillingClient.BillingResponse int billingResponse) {
                if (billingResponse == BillingClient.BillingResponse.OK) {
                    if (executeOnSuccess == null) {
                        getFragment().updateGUIAfterBillingConnected();
                    }
                    if (executeOnSuccess != null) {
                        executeOnSuccess.run();
                    }
                }
            /* else {
                        Log.w(TAG, "onBillingSetupFinished() error code: " + billingResponse);
                    }*/
            }

            @Override
            public void onBillingServiceDisconnected() {
            // Log.w(TAG, "onBillingServiceDisconnected()");
            }
        });
    }
}
Also used : BillingClientStateListener(com.android.billingclient.api.BillingClientStateListener) DonationFragment(sk.henrichg.phoneprofilesplus.DonationFragment)

Aggregations

BillingClientStateListener (com.android.billingclient.api.BillingClientStateListener)1 DonationFragment (sk.henrichg.phoneprofilesplus.DonationFragment)1