Loading QKSMS/src/main/java/com/moez/QKSMS/common/DonationManager.java +61 −70 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import android.widget.Toast; import com.moez.QKSMS.R; import com.moez.QKSMS.external.iab.IabHelper; import com.moez.QKSMS.external.iab.IabResult; import com.moez.QKSMS.external.iab.Inventory; import com.moez.QKSMS.external.iab.Purchase; import com.moez.QKSMS.ui.base.QKActivity; import com.moez.QKSMS.ui.dialog.QKDialog; Loading Loading @@ -37,6 +36,8 @@ public class DonationManager { public static DonationManager getInstance(QKActivity context) { if (sInstance == null) { sInstance = new DonationManager(context); } else { sInstance.mContext = context; // Update the context, in case the previous context was destroyed } return sInstance; Loading @@ -56,10 +57,7 @@ public class DonationManager { // Create the helper, passing it our context and the public key to verify signatures with mHelper = new IabHelper(mContext, PUBLIC_KEY); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { @Override public void onIabSetupFinished(IabResult result) { mHelper.startSetup(result -> { // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) { return; Loading @@ -76,7 +74,6 @@ public class DonationManager { // IAB is fully set up. Now, let's get an inventory of stuff we own. mHelper.queryInventoryAsync(iabInventoryListener()); } }); } Loading Loading @@ -119,9 +116,7 @@ public class DonationManager { * Listener that's called when we finish querying the items and subscriptions we own */ private IabHelper.QueryInventoryFinishedListener iabInventoryListener() { return new IabHelper.QueryInventoryFinishedListener() { @Override public void onQueryInventoryFinished(IabResult result, Inventory inventory) { return (result, inventory) -> { // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) { return; Loading Loading @@ -160,7 +155,6 @@ public class DonationManager { if (inventory.hasPurchase(SKU_DONATE_10)) { mHelper.consumeAsync(inventory.getPurchase(SKU_DONATE_10), onConsumeFinishedListener); } } }; } Loading @@ -180,9 +174,7 @@ public class DonationManager { public void showDonateDialog() { View.OnClickListener clickListener = new View.OnClickListener() { @Override public void onClick(View view) { View.OnClickListener clickListener = view -> { switch (view.getId()) { case R.id.donate_1: onDonateButtonClicked(SKU_DONATE_1); Loading @@ -197,7 +189,6 @@ public class DonationManager { donatePaypal(); break; } } }; View view = mContext.getLayoutInflater().inflate(R.layout.dialog_donate, null); Loading Loading
QKSMS/src/main/java/com/moez/QKSMS/common/DonationManager.java +61 −70 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ import android.widget.Toast; import com.moez.QKSMS.R; import com.moez.QKSMS.external.iab.IabHelper; import com.moez.QKSMS.external.iab.IabResult; import com.moez.QKSMS.external.iab.Inventory; import com.moez.QKSMS.external.iab.Purchase; import com.moez.QKSMS.ui.base.QKActivity; import com.moez.QKSMS.ui.dialog.QKDialog; Loading Loading @@ -37,6 +36,8 @@ public class DonationManager { public static DonationManager getInstance(QKActivity context) { if (sInstance == null) { sInstance = new DonationManager(context); } else { sInstance.mContext = context; // Update the context, in case the previous context was destroyed } return sInstance; Loading @@ -56,10 +57,7 @@ public class DonationManager { // Create the helper, passing it our context and the public key to verify signatures with mHelper = new IabHelper(mContext, PUBLIC_KEY); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { @Override public void onIabSetupFinished(IabResult result) { mHelper.startSetup(result -> { // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) { return; Loading @@ -76,7 +74,6 @@ public class DonationManager { // IAB is fully set up. Now, let's get an inventory of stuff we own. mHelper.queryInventoryAsync(iabInventoryListener()); } }); } Loading Loading @@ -119,9 +116,7 @@ public class DonationManager { * Listener that's called when we finish querying the items and subscriptions we own */ private IabHelper.QueryInventoryFinishedListener iabInventoryListener() { return new IabHelper.QueryInventoryFinishedListener() { @Override public void onQueryInventoryFinished(IabResult result, Inventory inventory) { return (result, inventory) -> { // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) { return; Loading Loading @@ -160,7 +155,6 @@ public class DonationManager { if (inventory.hasPurchase(SKU_DONATE_10)) { mHelper.consumeAsync(inventory.getPurchase(SKU_DONATE_10), onConsumeFinishedListener); } } }; } Loading @@ -180,9 +174,7 @@ public class DonationManager { public void showDonateDialog() { View.OnClickListener clickListener = new View.OnClickListener() { @Override public void onClick(View view) { View.OnClickListener clickListener = view -> { switch (view.getId()) { case R.id.donate_1: onDonateButtonClicked(SKU_DONATE_1); Loading @@ -197,7 +189,6 @@ public class DonationManager { donatePaypal(); break; } } }; View view = mContext.getLayoutInflater().inflate(R.layout.dialog_donate, null); Loading