Skip to content

Commit ce65e8a

Browse files
committed
Migrate to new APIs & ktx extension functions
1 parent 5f87dcd commit ce65e8a

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

composed-core/src/main/kotlin/com/w2sv/composed/core/Resources.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import androidx.annotation.StringRes
1919
import androidx.compose.runtime.Composable
2020
import androidx.compose.runtime.remember
2121
import androidx.compose.ui.graphics.Color
22-
import androidx.compose.ui.platform.LocalContext
2322
import androidx.compose.ui.platform.LocalDensity
23+
import androidx.compose.ui.platform.LocalResources
2424
import androidx.compose.ui.text.AnnotatedString
2525
import androidx.compose.ui.text.SpanStyle
2626
import androidx.compose.ui.text.buildAnnotatedString
@@ -33,6 +33,7 @@ import androidx.compose.ui.unit.Density
3333
import androidx.compose.ui.unit.dp
3434
import androidx.compose.ui.unit.em
3535
import androidx.core.text.HtmlCompat
36+
import androidx.core.text.toHtml
3637
import androidx.core.text.toSpanned
3738

3839
/**
@@ -49,7 +50,7 @@ import androidx.core.text.toSpanned
4950
*/
5051
@Composable
5152
fun rememberStyledTextResource(@StringRes id: Int, vararg formatArgs: Any): AnnotatedString {
52-
val resources = LocalContext.current.resources
53+
val resources = LocalResources.current
5354
val density = LocalDensity.current
5455
return remember(id, *formatArgs) {
5556
resources.getAnnotatedString(id, density, *formatArgs)
@@ -90,8 +91,8 @@ private fun Resources.getHtmlText(@StringRes id: Int, vararg args: Any): Spanned
9091
)
9192

9293
private fun Spanned.toHtmlWithoutParagraphs(): String =
93-
HtmlCompat
94-
.toHtml(this, HtmlCompat.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)
94+
this
95+
.toHtml()
9596
.substringAfter("<p dir=\"ltr\">")
9697
.substringBeforeLast("</p>")
9798

composed-core/src/main/kotlin/com/w2sv/composed/core/extensions/TimeInterpolator.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ import android.animation.TimeInterpolator
44
import androidx.compose.animation.core.Easing
55

66
fun TimeInterpolator.toEasing() =
7-
Easing {
8-
getInterpolation(it)
9-
}
7+
Easing { getInterpolation(it) }

0 commit comments

Comments
 (0)