YoKeyword / Fragmentation

[DEPRECATED] A powerful library that manage Fragment for Android
Apache License 2.0
9.72k stars 2.11k forks source link

为什么在Handler.post里调用onSupportVisible, 而不是直接调用? #1264

Closed shiqos closed 3 years ago

shiqos commented 3 years ago

为什么在Handler.post里调用onSupportVisible, 而不是直接调用?

发现在onHiddenChanged(false) 和 setUserVisibleHint(true)里会Post到MessageQueue里, 异步调用onSupportVisible

请问为什么不能直接调用呢, 直接调用会有什么问题么? https://github.com/YoKeyword/Fragmentation/blob/0394930a3e2368f210df31f2632fb89b9c44e121/fragmentation_core/src/main/java/me/yokeyword/fragmentation/helper/internal/VisibleDelegate.java#L162

shiqos commented 3 years ago

通过这些patch https://github.com/YoKeyword/Fragmentation/commit/38f80c6e04a2b22bd4de82f13c7a5acad648731c https://github.com/YoKeyword/Fragmentation/commit/6191af56f3c7f8926b161a7b1776170cf4e700b2 以及https://github.com/YoKeyword/Fragmentation/issues/475 可知使用post方式回调onSupportVisible为了解决 方法回调时序的问题 不能改成直接调用

该issue关闭