Skip to content

Commit a73d3b4

Browse files
authored
Refactor(text): Use KTX extension for isDigitsOnly check (#593)
The lint tool reported a "UseKtx" warning in StateBasedText.kt. The code was using the static `TextUtils.isDigitsOnly()` method. This commit refactors the code to use the more idiomatic `isDigitsOnly()` Kotlin extension function from the Android KTX library.
1 parent 3c8b283 commit a73d3b4

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/text/StateBasedText.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616

1717
package com.example.compose.snippets.text
18-
19-
import android.text.TextUtils
2018
import androidx.compose.foundation.layout.Column
2119
import androidx.compose.foundation.layout.Spacer
2220
import androidx.compose.foundation.layout.height
@@ -249,7 +247,7 @@ class CustomInputTransformation : InputTransformation {
249247
// [START android_compose_state_text_16]
250248
class DigitOnlyInputTransformation : InputTransformation {
251249
override fun TextFieldBuffer.transformInput() {
252-
if (!TextUtils.isDigitsOnly(asCharSequence())) {
250+
if (!asCharSequence().isDigitsOnly()) {
253251
revertAllChanges()
254252
}
255253
}

0 commit comments

Comments
 (0)