Using buildString{} inline method to improve readability

This commit is contained in:
Maxime NATUREL 2022-09-08 13:57:23 +02:00
parent 3970c2ec31
commit 51fba85a3a
2 changed files with 12 additions and 10 deletions

View file

@ -92,13 +92,14 @@ class SessionInfoView @JvmOverloads constructor(
private fun appendLearnMoreToVerificationStatus() {
val status = views.sessionInfoVerificationStatusDetailTextView.text
val learnMore = context.getString(R.string.action_learn_more)
val stringBuilder = StringBuilder()
stringBuilder.append(status)
stringBuilder.append(" ")
stringBuilder.append(learnMore)
val statusText = buildString {
append(status)
append(" ")
append(learnMore)
}
views.sessionInfoVerificationStatusDetailTextView.setTextWithColoredPart(
fullText = stringBuilder.toString(),
fullText = statusText,
coloredPart = learnMore,
underline = false
) {

View file

@ -65,14 +65,15 @@ class SessionsListHeaderView @JvmOverloads constructor(
}
val learnMore = context.getString(R.string.action_learn_more)
val stringBuilder = StringBuilder()
stringBuilder.append(description)
stringBuilder.append(" ")
stringBuilder.append(learnMore)
val fullDescription = buildString {
append(description)
append(" ")
append(learnMore)
}
binding.sessionsListHeaderDescription.isVisible = true
binding.sessionsListHeaderDescription.setTextWithColoredPart(
fullText = stringBuilder.toString(),
fullText = fullDescription,
coloredPart = learnMore,
underline = false
) {