()
| 117 | } |
| 118 | |
| 119 | public void updatePurchases() throws RemoteException { |
| 120 | // Get purchases |
| 121 | List<String> skus = new ArrayList<>(); |
| 122 | skus.addAll(getPurchases("inapp")); |
| 123 | skus.addAll(getPurchases("subs")); |
| 124 | |
| 125 | SharedPreferences prefs = context.getSharedPreferences("IAB", Context.MODE_PRIVATE); |
| 126 | SharedPreferences.Editor editor = prefs.edit(); |
| 127 | for (String product : prefs.getAll().keySet()) |
| 128 | if (!ActivityPro.SKU_DONATION.equals(product)) { |
| 129 | Log.i(TAG, "removing SKU=" + product); |
| 130 | editor.remove(product); |
| 131 | } |
| 132 | for (String sku : skus) { |
| 133 | Log.i(TAG, "adding SKU=" + sku); |
| 134 | editor.putBoolean(sku, true); |
| 135 | } |
| 136 | editor.apply(); |
| 137 | } |
| 138 | |
| 139 | public boolean isPurchased(String sku, String type) throws RemoteException { |
| 140 | return getPurchases(type).contains(sku); |
no test coverage detected