Skip to content

Commit

Permalink
docs: 补充注释说明
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaocydx committed May 27, 2024
1 parent 7492448 commit d276d4c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ class ImeAnimationCompatActivity : AppCompatActivity() {
// 该函数能避免跟window.modifyImeAnimation()的实现产生冲突。
window.setWindowInsetsAnimationCallbackCompat(
object : WindowInsetsAnimationCompat.Callback(DISPATCH_MODE_STOP) {
override fun onPrepare(animation: WindowInsetsAnimationCompat) {
// 此时未修改animation.durationMillis和animation.interpolator
super.onPrepare(animation)
}

override fun onStart(
animation: WindowInsetsAnimationCompat,
bounds: WindowInsetsAnimationCompat.BoundsCompat
): WindowInsetsAnimationCompat.BoundsCompat {
// 此时已修改animation.durationMillis和animation.interpolator
return super.onStart(animation, bounds)
}

override fun onProgress(
insets: WindowInsetsCompat,
runningAnimations: MutableList<WindowInsetsAnimationCompat>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ private class InsetsAnimationCompat private constructor(window: Window) : Window
insetsCallback!!.typeMask = typeMask
insetsCallback!!.durationMillis = durationMillis
insetsCallback!!.interpolator = interpolator
// 对视图树的根View(排除ViewRootImpl)decorView设置insetsCallback,
// 是为了避免WindowInsetsAnimation.Callback分发的过程产生歧义,例如:
// 对decorView设置insetsCallback,是为了避免分发产生歧义:
// decorView.setWindowInsetsAnimationCallback(callback)
// childView.setWindowInsetsAnimationCallback(insetsCallback)
// 1. callback的dispatchMode是DISPATCH_MODE_CONTINUE_ON_SUBTREE。
Expand Down Expand Up @@ -220,7 +219,7 @@ private class InsetsAnimationCompat private constructor(window: Window) : Window
*
* [onStart]修改第4步的[WindowInsetsAnimation],[onDraw]修改第6步构建的属性动画。
*
* 选择在[onDraw]修改第6步构建的属性动画的原因:
* [onDraw]修改第6步构建的属性动画的原因:
* 最初是在[onStart]修改`InsetsController.SYNC_IME_INTERPOLATOR`,使得第6步获取修改结果构建属性动画,
* 但部分设备的`InsetsController.InternalAnimationControlListener.getInsetsInterpolator()`不会获取
* 修改结果构建属性动画,导致`durationMillis`修改成功,`interpolator`修改失败。
Expand Down

0 comments on commit d276d4c

Please sign in to comment.