-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nullability and javadocs #293
Changes from 5 commits
8489dfa
bfe53ac
346cf1f
7d3f8f8
0ffcb9f
5a1e03b
b281e51
329c287
88354f0
13b225e
1bd767b
8472229
49edd02
abd3e16
0f57195
4936ea3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ android { | |
dependencies { | ||
androidTestCompile 'com.android.support.test:runner:0.5' | ||
androidTestCompile 'com.android.support.test:rules:0.5' | ||
compile 'com.android.support:support-annotations:25.3.1' | ||
} | ||
|
||
configurations.archives.extendsFrom configurations.default | ||
|
@@ -69,8 +70,10 @@ uploadArchives { | |
repositories.mavenDeployer { | ||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } | ||
|
||
repository(url: sonatypeRepo) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran into the same issue. I end up keeping this in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a gradle.properties file and put a blank value there There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @serggl if this is in your gradle property file, how about I just add a check to see if the value is defined? It'll be something along the lines of if property file exists or variable exists in System.env (for travis), then execute the call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. Can you add it?:) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @serggl done. It looks like you also added fake properties in the travis yml, so I removed those as it won't be necessary |
||
authentication(userName: sonatypeUsername, password: sonatypePassword) | ||
if (project.hasProperty('sonatypeRepo')) { | ||
repository(url: sonatypeRepo) { | ||
authentication(userName: sonatypeUsername, password: sonatypePassword) | ||
} | ||
} | ||
|
||
pom.project { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import android.os.Bundle; | ||
import android.os.IBinder; | ||
import android.os.RemoteException; | ||
import android.support.annotation.Nullable; | ||
import android.text.TextUtils; | ||
import android.util.Log; | ||
|
||
|
@@ -36,6 +37,7 @@ | |
import org.json.JSONObject; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Calendar; | ||
import java.util.Collections; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
@@ -49,17 +51,17 @@ public class BillingProcessor extends BillingBase | |
*/ | ||
public interface IBillingHandler | ||
{ | ||
void onProductPurchased(String productId, TransactionDetails details); | ||
void onProductPurchased(String productId, @Nullable TransactionDetails details); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if productId is nullable. As of now I don't think it is |
||
|
||
void onPurchaseHistoryRestored(); | ||
|
||
void onBillingError(int errorCode, Throwable error); | ||
void onBillingError(int errorCode, @Nullable Throwable error); | ||
|
||
void onBillingInitialized(); | ||
} | ||
|
||
private static final Date DATE_MERCHANT_LIMIT_1 = new Date(2012, 12, 5); //5th December 2012 | ||
private static final Date DATE_MERCHANT_LIMIT_2 = new Date(2015, 7, 20); //21st July 2015 | ||
private static final Date DATE_MERCHANT_LIMIT_1 = new Date(1354694400000L); //5th December 2012 | ||
private static final Date DATE_MERCHANT_LIMIT_2 = new Date(1437375600000L); //21st July 2015 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace with millis, since using the original notation may not produce expected results. See stack overflow. Based on PST There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any other options as a replacement? This is a bit less readable code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @serggl see latest commit. I'm 99% sure that that is how calendars are used, so it should be good. The date will likely vary based on timezones, but it shouldn't be off by more than a day. |
||
|
||
private static final int PURCHASE_FLOW_REQUEST_CODE = 32459; | ||
private static final String LOG_TAG = "iabv3"; | ||
|
@@ -296,10 +298,14 @@ private boolean loadPurchasesByType(String type, BillingCache cacheStorage) | |
return false; | ||
} | ||
|
||
/** | ||
* Attempt to fetch purchases from the server and update our cache if successful | ||
* @return {@code true} if retrieval occurs, {@code false} otherwise | ||
* todo check if loading should return true if response code isn't successful | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it does returns false when unsuccessful from here: https://github.com/anjlab/android-inapp-billing-v3/blob/master/library/src/main/java/com/anjlab/android/iab/v3/BillingProcessor.java#L296 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, right. Should return false here if response was not successful There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved b281e51 |
||
*/ | ||
public boolean loadOwnedPurchasesFromGoogle() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the load methods return true so long as a response is received, regardless of whether the response was successful or not. I also removed the first |
||
{ | ||
return isInitialized() && | ||
loadPurchasesByType(Constants.PRODUCT_TYPE_MANAGED, cachedProducts) && | ||
return loadPurchasesByType(Constants.PRODUCT_TYPE_MANAGED, cachedProducts) && | ||
loadPurchasesByType(Constants.PRODUCT_TYPE_SUBSCRIPTION, cachedSubscriptions); | ||
} | ||
|
||
|
@@ -328,7 +334,7 @@ public boolean subscribe(Activity activity, String productId, String developerPa | |
* | ||
* @param activity the activity calling this method | ||
* @param productId the product id to purchase | ||
* @param extraParamsBundle A bundle object containing extra parameters to pass to | ||
* @param extraParams A bundle object containing extra parameters to pass to | ||
* getBuyIntentExtraParams() | ||
* @see <a href="https://developer.android.com/google/play/billing/billing_reference.html#getBuyIntentExtraParams">extra | ||
* params documentation on developer.android.com</a> | ||
|
@@ -352,7 +358,7 @@ public boolean purchase(Activity activity, String productId, String developerPay | |
* | ||
* @param activity the activity calling this method | ||
* @param productId the product id to purchase | ||
* @param extraParamsBundle A bundle object containing extra parameters to pass to getBuyIntentExtraParams() | ||
* @param extraParams A bundle object containing extra parameters to pass to getBuyIntentExtraParams() | ||
* @see <a href="https://developer.android.com/google/play/billing/billing_reference.html#getBuyIntentExtraParams">extra | ||
* params documentation on developer.android.com</a> | ||
* @return {@code false} if the billing system is not initialized, {@code productId} is empty or if an exception occurs. | ||
|
@@ -610,6 +616,7 @@ private boolean purchase(Activity activity, List<String> oldProductIds, String p | |
purchaseType, | ||
purchasePayload); | ||
} | ||
//todo check if null check should be removed or if else should be removed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will always be nonnull given the if statement above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep. A remove candidate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I take it you mean that the null check if unnecessary. Resolved here 329c287 |
||
else // API v7+ supported | ||
{ | ||
if (extraParamsBundle == null) | ||
|
@@ -735,6 +742,7 @@ private boolean checkMerchant(TransactionDetails details) | |
return merchantId.compareTo(developerMerchantId) == 0; | ||
} | ||
|
||
@Nullable | ||
private TransactionDetails getPurchaseTransactionDetails(String productId, BillingCache cache) | ||
{ | ||
PurchaseInfo details = cache.getDetails(productId); | ||
|
@@ -865,11 +873,13 @@ public List<SkuDetails> getSubscriptionListingDetails(ArrayList<String> productI | |
return getSkuDetails(productIdList, Constants.PRODUCT_TYPE_SUBSCRIPTION); | ||
} | ||
|
||
@Nullable | ||
public TransactionDetails getPurchaseTransactionDetails(String productId) | ||
{ | ||
return getPurchaseTransactionDetails(productId, cachedProducts); | ||
} | ||
|
||
@Nullable | ||
public TransactionDetails getSubscriptionTransactionDetails(String productId) | ||
{ | ||
return getPurchaseTransactionDetails(productId, cachedSubscriptions); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am personally very much in support of adding nullability annotations. Useful for us Java users, too!