Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Osip Fatkullin <[email protected]>
  • Loading branch information
sonulen and osipxd authored Apr 16, 2024
1 parent 0db2b4b commit 78367c0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
}
dependencies {
// Fragment version
// Views version
implementation("com.redmadrobot.extensions:resources-ktx:1.3.1-0")
// Compose version
Expand Down Expand Up @@ -89,11 +89,11 @@ Dimension converters for `Context` (the same available for `Resources`):
**TextValue** is a wrapper to make it possible to work with plain `String` and `StringRes` in the same way.
It may be useful for cases when you want to fallback to `StringRes` if desired string value is `null`.

You can wrap `String` and `StringRes` into `TextValue` using `TextValue.Plain(String)` and `TextValue.Resource(Int)`, accordingly and use method `TextValue.get(Resource)` to retrieve `String`:
You can wrap `String` and `StringRes` with `TextValue` using `TextValue(String)`, `TextValue(Int)` or `TextValue(String?, Int))`, and use method `TextValue.get(Resource)` to retrieve `String`:

```kotlin
// in some place where we can't access Context
val errorMessage = exception.message?.let(TextValue::Plain) ?: TextValue.Resource(R.string.unknown_error)
val errorMessage = TextValue(exception.message, defaultResourceId = R.string.unknown_error)
showMessage(errorMessage)

// in Activity, Fragment or View
Expand Down

0 comments on commit 78367c0

Please sign in to comment.