Search in sources :

Example 1 with DonationFragment

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()");
            }
        });
    }
}
Also used : BillingClientStateListener(com.android.billingclient.api.BillingClientStateListener) BillingResult(com.android.billingclient.api.BillingResult) DonationFragment(sk.henrichg.phoneprofiles.DonationFragment)

Aggregations

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