Example #1
0
 @Override
 public void onRequestPurchaseResponse(RequestPurchase request, ResponseCode responseCode) {
   if (responseCode == ResponseCode.RESULT_OK) {
     UiUtils.showToast(getActivity(), "Donation request sent successfully");
   } else if (responseCode == ResponseCode.RESULT_USER_CANCELED) {
     UiUtils.showToast(getActivity(), "Donation request cancelled");
   } else {
     UiUtils.showToast(getActivity(), "Donation request failed");
   }
 }
Example #2
0
 @Override
 public void onClick(View v) {
   String productId = (String) v.getTag();
   if (!mBillingService.requestPurchase(productId, null)) {
     UiUtils.showToast(getActivity(), "Google Play billing service is not supported");
   }
 }
Example #3
0
 @Override
 public void onRestoreTransactionsResponse(
     RestoreTransactions request, ResponseCode responseCode) {
   Log.d("onRestoreTransactionsResponse", responseCode.toString());
   if (responseCode == ResponseCode.RESULT_OK) {
     // Update the shared preferences so that we don't perform
     // a RestoreTransactions again.
     SharedPreferences prefs = getActivity().getPreferences(Context.MODE_PRIVATE);
     SharedPreferences.Editor edit = prefs.edit();
     edit.putBoolean(DONATIONS_INITIALIZED, true);
     edit.commit();
     UiUtils.showToast(getActivity(), "Past donations restored successfully");
   } else {
     UiUtils.showToast(getActivity(), "Unable to restore donation transactions");
   }
   showDonationView(BILLING_AVAILABLE);
 }
Example #4
0
 private boolean restoreDatabase() {
   SharedPreferences prefs = getActivity().getPreferences(MODE_PRIVATE);
   boolean initialized = prefs.getBoolean(DONATIONS_INITIALIZED, false);
   if (!initialized) {
     mBillingService.restoreTransactions();
     UiUtils.showToast(getActivity(), "Restoring past donation transactions");
   }
   return initialized;
 }