SimpleBilling(@NonNull String packageName, @NonNull IInAppBillingService service) { this.packageName = checkNotNull(packageName, "packageName == null"); this.service = checkNotNull(service, "service == null"); }
@Override public SkuDetails skuDetails(@NonNull String sku) { try { final Bundle skus = new Bundle(1); skus.putStringArrayList(REQUEST_ITEM_ID_LIST, arrayList(sku)); final Bundle bundle = service.getSkuDetails(3, packageName, BILLING_TYPE, skus); if (responseOk(bundle)) { final ArrayList<String> list = bundle.getStringArrayList(RESPONSE_DETAILS_LIST); if (list != null && !list.isEmpty()) { final String json = list.get(0); return new SkuDetails(json); } } } catch (RemoteException | JSONException ignore) { } return null; }
@WorkerThread @Nullable @Override public Purchase load() { final String json = prefs.getString(PURCHASE_JSON, null); if (!isBlank(json)) { final String signature = prefs.getString(PURCHASE_SIGNATURE, null); try { return new Purchase(json, signature); } catch (JSONException ignore) { } } return null; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final Purchase purchase = (Purchase) o; return autoRenewing == purchase.autoRenewing && purchaseTime == purchase.purchaseTime && purchaseState == purchase.purchaseState && orderId.equals(purchase.orderId) && packageName.equals(purchase.packageName) && sku.equals(purchase.sku) && developerPayload.equals(purchase.developerPayload) && purchaseToken.equals(purchase.purchaseToken) && safeEquals(signature, purchase.signature); }
private static Bundle populateLSuccessfulList(@NonNull String key, @Nullable String... values) { final ArrayList<String> list; if (values == null) { list = null; } else { list = arrayList(values); } final Bundle bundle = new Bundle(2); bundle.putInt(RESPONSE_CODE, BILLING_RESPONSE_RESULT_OK); bundle.putStringArrayList(key, list); return bundle; } }
if (isBlank(purchaseData)) { listener.onPurchaseBadResponse(data); return true;
@Override public Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken) throws RemoteException { final Bundle bundle = responseOkBundle(); bundle.putStringArrayList(RESPONSE_ITEM_LIST, arrayList(SKU)); return bundle; }
/** * {@inheritDoc} */ @NonNull public Builder listener(@NonNull PremiumerListener listener) { this.listener = checkNotNull(listener, "listener == null"); return this; }
@Override public Bundle getSkuDetails(int apiVersion, String packageName, String type, Bundle skusBundle) throws RemoteException { final Bundle bundle = responseOkBundle(); bundle.putStringArrayList(RESPONSE_DETAILS_LIST, arrayList(JSON_SKU)); return bundle; }
SimpleBinder(@NonNull Context context) { this.context = checkNotNull(context, "context == null"); }
@Test public void hasBillingCapabilitiesOk() { final List<ResolveInfo> list = arrayList(mock(ResolveInfo.class)); final Context context = new SimpleBinderContext(list); assertBillingCapabilities(context, true); }
/** * {@inheritDoc} */ @NonNull public Builder purchaseVerifier(@NonNull PurchaseVerifier verifier) { this.purchaseVerifier = checkNotNull(verifier, "verifier == null"); return this; }
/** * {@inheritDoc} */ @NonNull public Builder purchaseCache(@NonNull PurchaseCache cache) { this.purchaseCache = checkNotNull(cache, "cache == null"); return this; }
/** * {@inheritDoc} */ @NonNull public Builder signatureBase64(@NonNull String signatureBase64) { this.signatureBase64 = checkNotNull(signatureBase64, "signatureBase64 == null"); return this; }
/** * {@inheritDoc} */ @NonNull @Override public ListenerProvider sku(@NonNull String sku) { this.sku = checkNotNull(sku, "sku == null"); return this; }
/** * {@inheritDoc} */ @NonNull public Builder payloadGenerator(@NonNull PayloadGenerator generator) { this.payloadGenerator = checkNotNull(generator, "generator == null"); return this; }
/** * {@inheritDoc} */ @NonNull public Builder executor(@NonNull Executor executor) { this.executor = checkNotNull(executor, "executor == null"); return this; }
SharedPrefsCache(@NonNull Context context) { checkNotNull(context, "context == null"); prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); }
PremiumerHandler(@NonNull PremiumerListener listener) { super(Looper.getMainLooper()); this.listener = checkNotNull(listener, "listener == null"); }
private PremiumerBuilder(@NonNull Context context) { this.context = checkNotNull(context, "context == null").getApplicationContext(); }