Skip to content

Commit c74c123

Browse files
committed
1,优化代码
1 parent 1fc0fd5 commit c74c123

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

FormatTextView/src/main/java/com/flyjingfish/formattextview/FormatTextView.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ import android.util.AttributeSet
1515
import android.util.LayoutDirection
1616
import android.view.View
1717
import androidx.annotation.StringRes
18-
import java.lang.NullPointerException
1918
import androidx.core.text.TextUtilsCompat
2019
import java.util.*
21-
import kotlin.math.max
2220

2321

2422
class FormatTextView : BaseTextView {
@@ -83,8 +81,8 @@ class FormatTextView : BaseTextView {
8381
}
8482

8583
fun setFormatText(formatTextValue: String, vararg args: Int) {
86-
val formatTexts: Array<FormatText?> = arrayOfNulls<FormatText>(args.size)
87-
for (i in 0 until args.size) {
84+
val formatTexts: Array<FormatText?> = arrayOfNulls(args.size)
85+
for (i in args.indices) {
8886
formatTexts[i] = FormatText().setResValue(args[i])
8987
}
9088
setFormatTextBean(formatTextValue, *formatTexts)
@@ -95,8 +93,8 @@ class FormatTextView : BaseTextView {
9593
}
9694

9795
fun setFormatText(formatTextValue: String, vararg args: String) {
98-
val formatTexts: Array<FormatText?> = arrayOfNulls<FormatText>(args.size)
99-
for (i in 0 until args.size) {
96+
val formatTexts: Array<FormatText?> = arrayOfNulls(args.size)
97+
for (i in args.indices) {
10098
formatTexts[i] = FormatText().setStrValue(args[i])
10199
}
102100
setFormatTextBean(formatTextValue, *formatTexts)

0 commit comments

Comments
 (0)