Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

修复ViewPager快速切换时,Fab可能出现状态不对的问题 #56

Merged
merged 1 commit into from Sep 25, 2017
Merged

Conversation

GuJin
Copy link

@GuJin GuJin commented Sep 25, 2017

问题原因

ViewPager 切换时,Fab 调用了 hide() 方法。
如果 Fab 尚未完全隐藏时,ViewPager 再次切换,则 Fab 会忽略此次 hide() 操作。(可参看 FloatingActionButtonIcs 源码中 isOrWillBeHidden() 方法和 mAnimState属性。)
而 Fab 的 onHidden() 回调中,使用的 position 被 final 修饰,导致快速切换时,回调中的 position 可能与当前不符,最终导致 ViewPager 快速切换时,Fab可能出现状态不对的问题。

解决方案

使用内部类替换 FloatingActionButton.OnVisibilityChangedListener 的匿名内部类,避免 position 被 final
修饰。

@xcc3641 xcc3641 merged commit 3cf24da into xcc3641:master Sep 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants