Skip to content
This repository was archived by the owner on Feb 17, 2020. It is now read-only.

Commit e3cf936

Browse files
committed
Make fromHtml(String) an extension function of String
1 parent 553c133 commit e3cf936

6 files changed

Lines changed: 12 additions & 12 deletions

File tree

app/src/main/java/net/squanchy/eventdetails/widget/EventDetailsLayout.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ class EventDetailsLayout @JvmOverloads constructor(
6868
builder.append(" ")
6969
.append(floorLabel)
7070
.setSpan(
71-
createColorSpan(whereValue, android.R.attr.textColorSecondary),
72-
builder.length - floorLabel.length,
73-
builder.length,
74-
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
71+
createColorSpan(whereValue, android.R.attr.textColorSecondary),
72+
builder.length - floorLabel.length,
73+
builder.length,
74+
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
7575
)
7676
}
7777
return builder
@@ -110,7 +110,7 @@ class EventDetailsLayout @JvmOverloads constructor(
110110
private fun updateDescription(description: Option<String>) {
111111
if (description.isDefined()) {
112112
descriptionGroup.isVisible = true
113-
descriptionValue.text = parseHtml(description.getOrThrow())
113+
descriptionValue.text = description.getOrThrow().parseHtml()
114114
} else {
115115
descriptionGroup.isVisible = false
116116
}

app/src/main/java/net/squanchy/favorites/view/FavoritesSignedInEmptyLayout.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class FavoritesSignedInEmptyLayout @JvmOverloads constructor(
3434

3535
@RequiresApi(Build.VERSION_CODES.N)
3636
override fun showAchievement(message: String) {
37-
Snackbar.make(this, parseHtml(message), Snackbar.LENGTH_LONG).show()
37+
Snackbar.make(this, message.parseHtml(), Snackbar.LENGTH_LONG).show()
3838
}
3939

4040
private val favoriteButtonClickListener = View.OnClickListener {

app/src/main/java/net/squanchy/speaker/widget/SpeakerDetailsLayout.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ class SpeakerDetailsLayout(context: Context, attrs: AttributeSet) : ConstraintLa
1111

1212
fun updateWith(speaker: Speaker) {
1313
speakerDetailsHeader.updateWith(speaker)
14-
speakerBio.text = parseHtml(speaker.bio)
14+
speakerBio.text = speaker.bio.parseHtml()
1515
}
1616
}

app/src/main/java/net/squanchy/support/text/Html.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import android.text.Html
66
import android.text.Spanned
77

88
@TargetApi(Build.VERSION_CODES.N) // The older fromHtml() is only called pre-24
9-
internal fun parseHtml(rawHtml: String): Spanned {
9+
internal fun String.parseHtml(): Spanned {
1010
// TODO use Dante (see https://github.com/squanchy-dev/squanchy-android/issues/322)
1111
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
12-
Html.fromHtml(rawHtml, Html.FROM_HTML_MODE_LEGACY)
12+
Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY)
1313
} else {
1414
@Suppress("DEPRECATION") // This is a "compat" method call, we only use this on pre-N
15-
Html.fromHtml(rawHtml)
15+
Html.fromHtml(this)
1616
}
1717
}

app/src/main/java/net/squanchy/tweets/view/TweetUrlSpanFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class TweetUrlSpanFactory(private val context: Context) {
9090

9191
if (matcher.find()) {
9292
val matchResult = matcher.toMatchResult()
93-
val unescapedEntity = parseHtml(matchResult.group())
93+
val unescapedEntity = matchResult.group().parseHtml()
9494
builder.replace(matchResult.start(), matchResult.end(), unescapedEntity)
9595
unescapeEntities(builder)
9696
}

app/src/main/java/net/squanchy/venue/VenueInfoPageView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class VenueInfoPageView @JvmOverloads constructor(
7373
private fun updateWith(venue: Venue) {
7474
venueName.text = venue.name
7575
venueAddress.text = venue.address
76-
venueDescription.text = parseHtml(venue.description)
76+
venueDescription.text = venue.description.parseHtml()
7777
loadMap(venueMap, venue.mapUrl, imageLoader)
7878
updateMapClickListenerWith(venue)
7979
}

0 commit comments

Comments
 (0)