[feedback]编辑框字数逻辑优化
This commit is contained in:
@@ -51,6 +51,8 @@ internal class BadCaseFBViewHolder(cb: IFeedbackCallback?, parent: ViewGroup): F
|
||||
itemView.findViewById<TextView>(R.id.words_count)
|
||||
}
|
||||
|
||||
private var first = false
|
||||
|
||||
init {
|
||||
itemView.findViewById<TextView>(R.id.record).also {
|
||||
it.background = gradient(radius = 16.PX, orientation = LEFT_RIGHT, centerX = 0.06f, startColor = Color.rgb(35, 146, 252), endColor = Color.rgb(28, 75, 252))
|
||||
@@ -88,10 +90,16 @@ internal class BadCaseFBViewHolder(cb: IFeedbackCallback?, parent: ViewGroup): F
|
||||
et.watch(
|
||||
200,
|
||||
onCountChanged = {
|
||||
if (first) {
|
||||
return@watch
|
||||
}
|
||||
words.visibility = View.VISIBLE
|
||||
words.spannableText(listOf(it.toString(), "/200"), listOf(Color.parseColor("#5EBFFF"), Color.WHITE))
|
||||
},
|
||||
onTextChanged = {
|
||||
if (it?.length ?: 0 > 0) {
|
||||
first = false
|
||||
}
|
||||
data().remark.text = it?.toString() ?: ""
|
||||
},
|
||||
onReachMaxCountAction = {
|
||||
@@ -112,7 +120,10 @@ internal class BadCaseFBViewHolder(cb: IFeedbackCallback?, parent: ViewGroup): F
|
||||
words.visibility = View.VISIBLE
|
||||
} else {
|
||||
words.visibility = View.INVISIBLE
|
||||
et.setText("")
|
||||
if (!first) {
|
||||
first = true
|
||||
et.setText("")
|
||||
}
|
||||
et.isCursorVisible = false
|
||||
etParent.background = shape(solid = Color.parseColor("#263869"), radius = 20.PX)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user