[feedback]优化编辑框状态变化

This commit is contained in:
renwj
2022-03-22 18:32:30 +08:00
parent 80802ea074
commit 229debcd4b

View File

@@ -47,6 +47,10 @@ internal class BadCaseFBViewHolder(cb: IFeedbackCallback?, parent: ViewGroup): F
itemView.findViewById<View>(R.id.et_root)
}
private val words by lazy {
itemView.findViewById<TextView>(R.id.words_count)
}
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))
@@ -63,7 +67,7 @@ internal class BadCaseFBViewHolder(cb: IFeedbackCallback?, parent: ViewGroup): F
etParent.also {
it.background = shape(solid = Color.parseColor("#263869"), radius = 20.PX)
}
val words = itemView.findViewById<TextView>(R.id.words_count)
val action = Runnable { KeyboardUtils.showSoftInput(et) }
et.onDetach {
et.removeCallbacks(action)
@@ -84,6 +88,7 @@ internal class BadCaseFBViewHolder(cb: IFeedbackCallback?, parent: ViewGroup): F
et.watch(
200,
onCountChanged = {
words.visibility = View.VISIBLE
words.spannableText(listOf(it.toString(), "/200"), listOf(Color.parseColor("#5EBFFF"), Color.WHITE))
},
onTextChanged = {
@@ -101,9 +106,14 @@ internal class BadCaseFBViewHolder(cb: IFeedbackCallback?, parent: ViewGroup): F
val text = data.remark.text
if (!TextUtils.isEmpty(text)) {
et.setText(text)
et.isCursorVisible = true
Selection.setSelection(et.text, et.text.length)
etParent.background = shape(solid = Color.parseColor("#263869"), radius = 20.PX, stroke = Color.parseColor("#5EBFFF"), strokeWidth = 2.PX)
words.visibility = View.VISIBLE
} else {
words.visibility = View.INVISIBLE
et.setText("")
et.isCursorVisible = false
etParent.background = shape(solid = Color.parseColor("#263869"), radius = 20.PX)
}
}