use of com.frostwire.android.offers.PlayStore in project frostwire by frostwire.
the class BuyActivity method initProductCards.
private void initProductCards(int lastSelectedCardViewId) {
card30days = findView(R.id.activity_buy_product_card_30_days);
card1year = findView(R.id.activity_buy_product_card_1_year);
card6months = findView(R.id.activity_buy_product_card_6_months);
final PlayStore store = PlayStore.getInstance();
initProductCard(card30days, store, Products.SUBS_DISABLE_ADS_1_MONTH_SKU, Products.INAPP_DISABLE_ADS_1_MONTH_SKU);
initProductCard(card1year, store, Products.SUBS_DISABLE_ADS_1_YEAR_SKU, Products.INAPP_DISABLE_ADS_1_YEAR_SKU);
initProductCard(card6months, store, Products.SUBS_DISABLE_ADS_6_MONTHS_SKU, Products.INAPP_DISABLE_ADS_6_MONTHS_SKU);
View.OnClickListener cardClickListener = new ProductCardViewOnClickListener();
card30days.setOnClickListener(cardClickListener);
card1year.setOnClickListener(cardClickListener);
card6months.setOnClickListener(cardClickListener);
initLastCardSelection(lastSelectedCardViewId);
}
use of com.frostwire.android.offers.PlayStore in project frostwire by frostwire.
the class ApplicationFragment method setupStore.
private void setupStore(long purchaseTimestamp) {
Preference p = findPreference("frostwire.prefs.offers.buy_no_ads");
if (p != null && !Constants.IS_GOOGLE_PLAY_DISTRIBUTION) {
PreferenceCategory category = findPreference("frostwire.prefs.other_settings");
category.removePreference(p);
} else if (p != null) {
PlayStore playStore = PlayStore.getInstance();
playStore.refresh();
Collection<Product> purchasedProducts = Products.listEnabled(playStore, Products.DISABLE_ADS_FEATURE);
if (purchaseTimestamp == 0 && purchasedProducts != null && purchasedProducts.size() > 0) {
initRemoveAdsSummaryWithPurchaseInfo(p, purchasedProducts);
// otherwise, a BuyActivity intent has been configured on application_preferences.xml
} else if (purchaseTimestamp > 0 && (System.currentTimeMillis() - purchaseTimestamp) < 30000) {
p.setSummary(getString(R.string.processing_payment) + "...");
p.setOnPreferenceClickListener(null);
} else {
p.setSummary(R.string.remove_ads_description);
p.setOnPreferenceClickListener(preference -> {
PlayStore.getInstance().endAsync();
Intent intent = new Intent(getActivity(), BuyActivity.class);
startActivityForResult(intent, BuyActivity.PURCHASE_SUCCESSFUL_RESULT_CODE);
return true;
});
}
}
}
use of com.frostwire.android.offers.PlayStore in project frostwire by frostwire.
the class BuyActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
PlayStore store = PlayStore.getInstance();
if (store.handleActivityResult(requestCode, resultCode, data)) {
store.refresh();
// user clicked outside of the PlayStore purchase dialog
if (data != null && data.hasExtra("RESPONSE_CODE") && data.getIntExtra("RESPONSE_CODE", 0) != 0) {
paymentOptionsView.stopProgressBar();
LOG.info("onActivityResult -> purchase cancelled");
// finish();
return;
}
// make sure ads won't show on this session any more if we got a positive response.
Offers.stopAdNetworks(this);
// now we prepare a result for SettingsActivity since it won't know right away
// given the purchase process is asynchronous
LOG.info("onActivityResult -> purchase finished");
Intent result = new Intent();
result.putExtra(BuyActivity.EXTRA_KEY_PURCHASE_TIMESTAMP, System.currentTimeMillis());
setResult(BuyActivity.PURCHASE_SUCCESSFUL_RESULT_CODE, result);
finish();
}
}
Aggregations