Skip to content

Commit b84202b

Browse files
committed
feat: 对请求SimpleAnimation做更多的支持
current = null改为仍然运行动画,动画开始改为去除所有水滴指示器,是为了支持需要动画调度做滚动的场景,比如ScrollView包含多个EditText。
1 parent bc6aede commit b84202b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

inputview/src/main/kotlin/com/xiaocydx/inputview/EditTextManager.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ internal class EditTextManager(
144144
}
145145

146146
/**
147-
* 在实际场景中,交互可能是先选中[EditText]的文本内容,再点击其它地方切换[Editor],
148-
* 当动画开始时,隐藏左右水滴状指示器,避免动画运行时不断跨进程通信,进而造成卡顿。
147+
* 当动画开始时,隐藏水滴状指示器,避免动画运行时不断跨进程通信,进而造成卡顿。
148+
* 在实际场景中,交互可能是先选中[EditText]的内容,再点击其它地方切换[Editor],
149+
* 或者调用[EditorAnimator.requestSimpleAnimation]请求运行动画。
149150
*/
150151
private inner class HideTextSelectHandleOnStart : ReplicableAnimationCallback {
151-
override fun onAnimationStart(state: AnimationState) = forEach { handle ->
152-
handle.takeIf { it.hasTextSelectHandleLeftRight() }
153-
?.hideTextSelectHandle(keepFocus = state.isIme(state.current))
152+
override fun onAnimationStart(state: AnimationState) = forEach {
153+
it.hideTextSelectHandle(keepFocus = state.isIme(state.current))
154154
}
155155
}
156156

inputview/src/main/kotlin/com/xiaocydx/inputview/EditorAnimator.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ abstract class EditorAnimator(
145145
}
146146

147147
internal fun requestSimpleAnimation() {
148+
// 构建的record缺少startView和endView,不开放此函数
148149
runSimpleAnimationOnPreDraw(fromRequest = true)
149150
}
150151

@@ -156,9 +157,10 @@ abstract class EditorAnimator(
156157
}
157158

158159
private fun runSimpleAnimationOnPreDraw(fromRequest: Boolean) {
159-
if (host?.hasPendingChange() == true) return
160-
val current = host?.current ?: return
161-
val record = AnimationRecord(current, current, fromRequest = fromRequest)
160+
val host = host
161+
if (host == null || host.hasPendingChange()) return
162+
// host.current = null仍然运行动画,支持需要动画调度的场景
163+
val record = AnimationRecord(host.current, host.current, fromRequest = fromRequest)
162164
resetAnimationRecord(record)
163165
record.setAnimationStartOffset()
164166
record.setPreDrawRunSimpleAnimation {

0 commit comments

Comments
 (0)