Skip to content

Commit aea662c

Browse files
committed
invoke onProductPurchased on the main thread
1 parent 92aac75 commit aea662c

File tree

4 files changed

+17
-39
lines changed

4 files changed

+17
-39
lines changed

library/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ afterEvaluate {
6666

6767
groupId = 'com.anjlab.android.iab.v3'
6868
artifactId = 'library'
69-
version = '2.0.0.1'
69+
version = '2.0.1'
7070

7171
pom {
7272
name = 'Android In-App Billing v3 Library'

library/src/main/java/com/anjlab/android/iab/v3/BillingProcessor.java

+16-37
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ private void handleOwnedPurchaseTransaction(String productId)
720720
details = getSubscriptionPurchaseInfo(productId);
721721
}
722722

723-
eventHandler.onProductPurchased(productId, details);
723+
reportProductPurchased(productId, details);
724724
}
725725
}
726726

@@ -994,7 +994,7 @@ private void verifyAndCachePurchase(Purchase purchase)
994994
PurchaseInfo purchaseInfo = new PurchaseInfo(purchaseData,
995995
dataSignature,
996996
getPurchasePayload());
997-
eventHandler.onProductPurchased(productId, purchaseInfo);
997+
reportProductPurchased(productId, purchaseInfo);
998998
}
999999
}
10001000
else
@@ -1005,7 +1005,7 @@ private void verifyAndCachePurchase(Purchase purchase)
10051005
}
10061006
catch (Exception e)
10071007
{
1008-
Log.e(LOG_TAG, "Error in handleActivityResult", e);
1008+
Log.e(LOG_TAG, "Error in verifyAndCachePurchase", e);
10091009
reportBillingError(Constants.BILLING_ERROR_OTHER_ERROR, e);
10101010
}
10111011
savePurchasePayload(null);
@@ -1058,54 +1058,33 @@ private String getPurchasePayload()
10581058

10591059
private void reportBillingError(int errorCode, Throwable error)
10601060
{
1061-
if (eventHandler != null)
1061+
if (eventHandler != null && handler != null)
10621062
{
1063-
eventHandler.onBillingError(errorCode, error);
1063+
handler.post(() -> eventHandler.onBillingError(errorCode, error));
10641064
}
10651065
}
10661066

10671067
private void reportPurchasesSuccess(final IPurchasesResponseListener listener)
10681068
{
10691069
if (listener != null && handler != null)
10701070
{
1071-
handler.post(new Runnable()
1072-
{
1073-
@Override
1074-
public void run()
1075-
{
1076-
listener.onPurchasesSuccess();
1077-
}
1078-
});
1071+
handler.post(() -> listener.onPurchasesSuccess());
10791072
}
10801073
}
10811074

10821075
private void reportPurchasesError(final IPurchasesResponseListener listener)
10831076
{
10841077
if (listener != null && handler != null)
10851078
{
1086-
handler.post(new Runnable()
1087-
{
1088-
@Override
1089-
public void run()
1090-
{
1091-
listener.onPurchasesError();
1092-
}
1093-
});
1079+
handler.post(() -> listener.onPurchasesError());
10941080
}
10951081
}
10961082

10971083
private void reportSkuDetailsErrorCaller(final String error, final ISkuDetailsResponseListener listener)
10981084
{
10991085
if (listener != null && handler != null)
11001086
{
1101-
handler.post(new Runnable()
1102-
{
1103-
@Override
1104-
public void run()
1105-
{
1106-
listener.onSkuDetailsError(error);
1107-
}
1108-
});
1087+
handler.post(() -> listener.onSkuDetailsError(error));
11091088
}
11101089
}
11111090

@@ -1114,17 +1093,17 @@ private void reportSkuDetailsResponseCaller(@Nullable final List<SkuDetails> pro
11141093
{
11151094
if (listener != null && handler != null)
11161095
{
1117-
handler.post(new Runnable()
1118-
{
1119-
@Override
1120-
public void run()
1121-
{
1122-
listener.onSkuDetailsResponse(products);
1123-
}
1124-
});
1096+
handler.post(() -> listener.onSkuDetailsResponse(products));
11251097
}
11261098
}
11271099

1100+
private void reportProductPurchased(@NonNull String productId, @Nullable PurchaseInfo details)
1101+
{
1102+
if (eventHandler != null && handler != null)
1103+
{
1104+
handler.post(() -> eventHandler.onProductPurchased(productId, details));
1105+
}
1106+
}
11281107

11291108
private void handlePurchase(final Purchase purchase)
11301109
{

library/src/main/java/com/anjlab/android/iab/v3/Constants.java

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public class Constants
4848

4949
@Deprecated
5050
public static final int BILLING_ERROR_LOST_CONTEXT = 103;
51-
public static final int BILLING_ERROR_INVALID_DEVELOPER_PAYLOAD = 105;
5251
public static final int BILLING_ERROR_PRODUCT_ID_NOT_SPECIFIED = 106;
5352
public static final int BILLING_ERROR_OTHER_ERROR = 110;
5453
public static final int BILLING_ERROR_CONSUME_FAILED = 111;

sample/libs/anjlab-iabv3-current.jar

-2.22 KB
Binary file not shown.

0 commit comments

Comments
 (0)