Skip to content

Commit

Permalink
text model fix
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-sancov committed Apr 21, 2021
1 parent 8eb5b5b commit 267bd7f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/src/main/java/md/sancov/utils/model/Text.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ sealed class Text: Parcelable {
val isMultiline: Boolean get() = when (this) {
is Resource -> multiline
is Chars -> multiline
is Lambda -> false
else -> false
}

val isEmpty: Boolean get() = when (this) {
is Resource -> resourceId <= 0
is Chars -> sequence.isNullOrBlank()
is Lambda -> false
else -> false
}

fun resolve(ctx: Context): String? {
return when (this) {
is Resource -> if (resourceId == 0) null else ctx.getString(resourceId)
is Chars -> sequence.toString()
is Lambda -> lambda(ctx).toString()
else -> null
}
}
}

0 comments on commit 267bd7f

Please sign in to comment.