支付相关回调使用ui线程
This commit is contained in:
parent
55d58c86e5
commit
f79ec2a94e
File diff suppressed because one or more lines are too long
@ -110,25 +110,30 @@ public class PayClient extends Activity implements PurchasesUpdatedListener {
|
||||
}
|
||||
}
|
||||
if (hasErr) {
|
||||
purchaseUpdateCb("error parse purchase data", null);
|
||||
purchaseUpdateCb(null,"error parse purchase data", null);
|
||||
} else {
|
||||
purchaseUpdateCb(null, dataArr.toString());
|
||||
purchaseUpdateCb(null,null, dataArr.toString());
|
||||
}
|
||||
} else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED) {
|
||||
purchaseUpdateCb("user cancel buy", null);
|
||||
purchaseUpdateCb(null,"user cancel buy", null);
|
||||
} else {
|
||||
String errmsg = billingResult.getDebugMessage();
|
||||
if (errmsg.isEmpty()) {
|
||||
errmsg = "other error";
|
||||
}
|
||||
purchaseUpdateCb(errmsg, null);
|
||||
purchaseUpdateCb(null, errmsg, null);
|
||||
}
|
||||
}
|
||||
private void purchaseUpdateCb(String error, String dataStr) {
|
||||
if (mFunId != null && !mFunId.isEmpty()) {
|
||||
JcSDK.nativeCb(mFunId, error, dataStr);
|
||||
mFunId = null;
|
||||
private void purchaseUpdateCb(String funId, String error, String dataStr) {
|
||||
if (funId == null) {
|
||||
if (mFunId != null && !mFunId.isEmpty()) {
|
||||
runOnUiThread(() -> JcSDK.nativeCb(mFunId, error, dataStr));
|
||||
mFunId = null;
|
||||
}
|
||||
} else {
|
||||
runOnUiThread(() -> JcSDK.nativeCb(funId, error, dataStr));
|
||||
}
|
||||
|
||||
}
|
||||
private boolean parseProductDetails(JSONArray dataArr, ProductDetails skuDetails) {
|
||||
JSONObject data = new JSONObject();
|
||||
@ -181,9 +186,9 @@ public class PayClient extends Activity implements PurchasesUpdatedListener {
|
||||
}
|
||||
}
|
||||
if (hasErr) {
|
||||
JcSDK.nativeCb(funId, "parse product detail json error", null);
|
||||
purchaseUpdateCb(funId, "parse product detail json error", null);
|
||||
} else {
|
||||
JcSDK.nativeCb(funId, null, dataArr.toString());
|
||||
purchaseUpdateCb(funId, null, dataArr.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -204,20 +209,20 @@ public class PayClient extends Activity implements PurchasesUpdatedListener {
|
||||
}
|
||||
}
|
||||
if (hasErr) {
|
||||
JcSDK.nativeCb(funId, "error parse purchase data", null);
|
||||
purchaseUpdateCb(funId, "error parse purchase data", null);
|
||||
} else {
|
||||
JcSDK.nativeCb(funId, null, dataArr.toString());
|
||||
purchaseUpdateCb(funId, null, dataArr.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void buyOne(String funId, String productId, String orderId) {
|
||||
if (mFunId != null && !mFunId.isEmpty()) {
|
||||
JcSDK.nativeCb(funId, "another purchase is in progress", null);
|
||||
purchaseUpdateCb(funId, "another purchase is in progress", null);
|
||||
return;
|
||||
}
|
||||
if (!skuDetailsMap.containsKey(productId)) {
|
||||
JcSDK.nativeCb(funId, "product with : "+productId+ " not found", null);
|
||||
purchaseUpdateCb(funId, "product with : "+productId+ " not found", null);
|
||||
return;
|
||||
}
|
||||
ProductDetails productDetails = skuDetailsMap.get(productId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user