支付相关回调使用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) {
|
if (hasErr) {
|
||||||
purchaseUpdateCb("error parse purchase data", null);
|
purchaseUpdateCb(null,"error parse purchase data", null);
|
||||||
} else {
|
} else {
|
||||||
purchaseUpdateCb(null, dataArr.toString());
|
purchaseUpdateCb(null,null, dataArr.toString());
|
||||||
}
|
}
|
||||||
} else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED) {
|
} else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED) {
|
||||||
purchaseUpdateCb("user cancel buy", null);
|
purchaseUpdateCb(null,"user cancel buy", null);
|
||||||
} else {
|
} else {
|
||||||
String errmsg = billingResult.getDebugMessage();
|
String errmsg = billingResult.getDebugMessage();
|
||||||
if (errmsg.isEmpty()) {
|
if (errmsg.isEmpty()) {
|
||||||
errmsg = "other error";
|
errmsg = "other error";
|
||||||
}
|
}
|
||||||
purchaseUpdateCb(errmsg, null);
|
purchaseUpdateCb(null, errmsg, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void purchaseUpdateCb(String error, String dataStr) {
|
private void purchaseUpdateCb(String funId, String error, String dataStr) {
|
||||||
if (mFunId != null && !mFunId.isEmpty()) {
|
if (funId == null) {
|
||||||
JcSDK.nativeCb(mFunId, error, dataStr);
|
if (mFunId != null && !mFunId.isEmpty()) {
|
||||||
mFunId = null;
|
runOnUiThread(() -> JcSDK.nativeCb(mFunId, error, dataStr));
|
||||||
|
mFunId = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
runOnUiThread(() -> JcSDK.nativeCb(funId, error, dataStr));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private boolean parseProductDetails(JSONArray dataArr, ProductDetails skuDetails) {
|
private boolean parseProductDetails(JSONArray dataArr, ProductDetails skuDetails) {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
@ -181,9 +186,9 @@ public class PayClient extends Activity implements PurchasesUpdatedListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasErr) {
|
if (hasErr) {
|
||||||
JcSDK.nativeCb(funId, "parse product detail json error", null);
|
purchaseUpdateCb(funId, "parse product detail json error", null);
|
||||||
} else {
|
} 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) {
|
if (hasErr) {
|
||||||
JcSDK.nativeCb(funId, "error parse purchase data", null);
|
purchaseUpdateCb(funId, "error parse purchase data", null);
|
||||||
} else {
|
} else {
|
||||||
JcSDK.nativeCb(funId, null, dataArr.toString());
|
purchaseUpdateCb(funId, null, dataArr.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buyOne(String funId, String productId, String orderId) {
|
public void buyOne(String funId, String productId, String orderId) {
|
||||||
if (mFunId != null && !mFunId.isEmpty()) {
|
if (mFunId != null && !mFunId.isEmpty()) {
|
||||||
JcSDK.nativeCb(funId, "another purchase is in progress", null);
|
purchaseUpdateCb(funId, "another purchase is in progress", null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!skuDetailsMap.containsKey(productId)) {
|
if (!skuDetailsMap.containsKey(productId)) {
|
||||||
JcSDK.nativeCb(funId, "product with : "+productId+ " not found", null);
|
purchaseUpdateCb(funId, "product with : "+productId+ " not found", null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ProductDetails productDetails = skuDetailsMap.get(productId);
|
ProductDetails productDetails = skuDetailsMap.get(productId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user