本文整理汇总了Java中org.solovyev.android.checkout.RequestListener类的典型用法代码示例。如果您正苦于以下问题:Java RequestListener类的具体用法?Java RequestListener怎么用?Java RequestListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestListener类属于org.solovyev.android.checkout包,在下文中一共展示了RequestListener类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doVerify
import org.solovyev.android.checkout.RequestListener; //导入依赖的package包/类
@Override
protected void doVerify(@NonNull final List<Purchase> purchases, @NonNull final RequestListener<List<Purchase>> listener) {
// Prepare params
Purchase purchase = purchases.get(0);
boolean isSubscription = Configuration.getSubscriptionProductIds().contains(purchase.sku);
String purchaseType = isSubscription ? "subscription" : "product";
// Post purchase verification request
ApiRequestHandler apiRequestHandler = new ApiRequestHandler(Configuration.getPurchaseConfirmationUrl(purchaseType));
PurchasesVerificationPayload purchasesVerificationPayload = new PurchasesVerificationPayload(purchase);
boolean result = apiRequestHandler.post(purchasesVerificationPayload);
// Trigger success
if(result) {
listener.onSuccess(purchases);
}else{
listener.onError(apiRequestHandler.getStatusCode(), new PurchaseVerificationException(apiRequestHandler.getResponseText()));
}
}
示例2: makeRequestListener
import org.solovyev.android.checkout.RequestListener; //导入依赖的package包/类
private <T> RequestListener<T> makeRequestListener() {
return new RequestListener<T>() {
@Override
public void onSuccess(@Nonnull T result) {
reloadInventory();
}
@Override
public void onError(int response, @Nonnull Exception e) {
reloadInventory();
e.printStackTrace();
}
};
}
示例3: purchase
import org.solovyev.android.checkout.RequestListener; //导入依赖的package包/类
private void purchase(Sku sku) {
final RequestListener<Purchase> listener = makeRequestListener();
mCheckout.startPurchaseFlow(sku, null, listener);
}