Skip to content
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

remove joda dependency that was triggering an `UnsupportedOperationEx… #286

Merged
merged 4 commits into from
Jul 7, 2017

Conversation

moni890185
Copy link
Contributor

  • Avoid to use joda dependency since:
  1. it's an external dependency that can be incompatible with what other developers use: Question: joda-time remove #285
  2. it leaves the developer the flexibility to use his own formatter
  3. for how it is implemented it currently causes a crash UnsupportedOperationException
  4. for some of us this field is not needed and we can avoid to have this dependency

In general it's a good approach avoiding to add dependencies to libraries whenever possible

  • Avoid returning null as fallback for introductoryPriceText, but rather returns the default to avoid potential crash.

…ception`. Avoid returning null as fallback for the introductoryPriceText.
@@ -83,72 +77,65 @@ public SkuDetails(JSONObject source) throws JSONException
priceLong = source.optLong(Constants.RESPONSE_PRICE_MICROS);
priceValue = priceLong / 1000000d;
priceText = source.optString(Constants.RESPONSE_PRICE);
subscriptionPeriod = parsePeriod(source.optString(Constants.RESPONSE_SUBSCRIPTION_PERIOD, "P"));
subscriptionFreeTrialPeriod = parsePeriod(source.optString(Constants.RESPONSE_FREE_TRIAL_PERIOD, "P"));
haveTrialPeriod = subscriptionFreeTrialPeriod.toStandardSeconds().getSeconds() != 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we avoid renaming existing fields?

Copy link
Contributor Author

@moni890185 moni890185 Jul 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't renamed these fields, this diff is due to the line changes, in fact I have removed the haveTrialPeriod inserted in the previous PR #281 because it's pointless if we don't use joda, and here it's where it was crashing, because of the toStandardSeconds() that's not working for all formats.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seem like this field could be useful. We can determine its value using TextUtils.isEmpty(subscriptionFreeTrialPeriod) for instance

Other then this, LGTM

subscriptionPeriod = parsePeriod(source.optString(Constants.RESPONSE_SUBSCRIPTION_PERIOD, "P"));
subscriptionFreeTrialPeriod = parsePeriod(source.optString(Constants.RESPONSE_FREE_TRIAL_PERIOD, "P"));
haveTrialPeriod = subscriptionFreeTrialPeriod.toStandardSeconds().getSeconds() != 0;
subscriptionPeriod = source.optString(Constants.RESPONSE_SUBSCRIPTION_PERIOD, "P");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does "P" mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is from the last PR you merged https://github.com/anjlab/android-inapp-billing-v3/pull/281/files#diff-82bb12704ee8c87bd183b059a6972bffR86, where the guys set a default P for period.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess P was an argument to a parse method, not actually a default value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy to use the default as I did in my PR https://github.com/anjlab/android-inapp-billing-v3/pull/282/files#diff-82bb12704ee8c87bd183b059a6972bffR77, what he did was using the fallback "P" instead of the default empty "", and I left it because I thought it was more convenient to have this default for who needs this param. I will just use the default ref. https://github.com/stleary/JSON-java/blob/master/JSONObject.java#L1372

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@serggl serggl merged commit 18e555b into anjlab:master Jul 7, 2017
serggl added a commit that referenced this pull request Jul 7, 2017
showdpro pushed a commit to showdpro/android-inapp-billing-v3 that referenced this pull request Jul 13, 2021
anjlab#286)

* remove joda dependency that was triggering an `UnsupportedOperationException`. Avoid returning null as fallback for the introductoryPriceText.

* remove fallback for some skuDetails fields.

* insert booleans for checking whether there is a trialPeriod/introductoryPeriod or not.

* insert missing tests from previous PR.
showdpro pushed a commit to showdpro/android-inapp-billing-v3 that referenced this pull request Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants