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

Update minSdkVersion (from 21 to 24) #2564

Merged
merged 11 commits into from
Nov 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class LeaderboardProductItem(
?.split(";")
?.filter { it.contains("&#") }
?.reduce { total, new -> "$total$new" }
?.run { fromHtmlWithSafeApiCall(this) }
?.run { Html.fromHtml(this) }
?: plainTextCurrency
}

Expand All @@ -105,7 +105,7 @@ class LeaderboardProductItem(
* Output: DKK
*/
@Suppress("MaxLineLength") private val plainTextCurrency by lazy {
fromHtmlWithSafeApiCall(priceAmountHtmlTag)
Html.fromHtml(priceAmountHtmlTag)
.toString()
.replace(Regex("[0-9.,]"), "")
}
Expand Down Expand Up @@ -150,7 +150,7 @@ class LeaderboardProductItem(
* using the [SpannableStringBuilder] implementation in order to parse it
*/
private val link by lazy {
fromHtmlWithSafeApiCall(itemHtmlTag)
Html.fromHtml(itemHtmlTag)
Copy link
Member

Choose a reason for hiding this comment

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

For using the new API instead of the deprecated one, WDYT about something like this?

itemHtmlTag?.let { Html.fromHtml(it, Html.FROM_HTML_MODE_LEGACY) }
                  ?.run { this as? SpannableStringBuilder }
                 ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👋 @hichamboushaba !

I think maybe this change is enough for now, wdyt? 🤔

PS: I really don't want to change any of the functionality, even by that slight bit, not that it will change much, but you know, you can never be too careful, and then you need to really test that, even if you change that little bit.

Copy link
Member

Choose a reason for hiding this comment

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

Good point, and I think we are safe, when the argument is null, we were already calling Html#fromHtml(String) which proxies the call to the same function we are using now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly, once more, thank YOU Hicham ! 🙇

.run { this as? SpannableStringBuilder }
?.spansAsList()
?.firstOrNull()
Expand All @@ -173,10 +173,6 @@ class LeaderboardProductItem(
getSpans(0, length, URLSpan::class.java)
.toList()

private fun fromHtmlWithSafeApiCall(source: String?) = source?.let {
Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY)
} ?: Html.fromHtml(source)

/**
* Returns the second object of the Top Performer Item Array if exists
*/
Expand Down