YoKeyword / Fragmentation

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

在ViewPager中,多个Fragment都触发了onSupportVisible, #1186

Open littlezan opened 5 years ago

littlezan commented 5 years ago

使用的是最新版本fragmentation:1.3.7 在ViewPager中,多个Fragment都触发了onSupportVisible。 背景:

  1. viewpage中加载AFragment,BFragment,CFragment,DFragment。
  2. viewpager.setCurrentItem(2),页面跳转到BFragment
  3. AFragment,BFragment 都回调了onSupportVisible,都没有回调onSupportInvisible

问题:为什么AFragment回调onSupportVisible,此时AFragment是不可见状态,就算回调了onSupportVisible,为什么不触发onSupportInvisible呢?

问题2:当退出整个Activity之后,BFragment回调onSupportInvisible,AFragment没有回调onSupportInvisible,但是AFragment回调了onPause

具体日志:

2019-09-07 20:29:17.976 6239-6239/com.liulishuo.kion E/ReadAfter2GuangZhouFragment: lll onSupportVisible this = 131254879
2019-09-07 20:29:18.020 6239-6239/com.liulishuo.kion E/DialogueSelectOpenQuestionsV2Fragment: lll onSupportVisible this = 89648273
2019-09-07 20:29:25.966 6239-6239/com.liulishuo.kion E/DialogueSelectOpenQuestionsV2Fragment: lll onSupportInvisible this = 89648273 validQuestion = true

前面2条日志为,进入Activity中,后面1条日志为退出activity

littlezan commented 5 years ago

进一步定位到问题了,触发场景如下: 在进入到含viewpager的Activity中,初始化好viewpager的fragments后,viewpager.setCurrentItem(1)会出现该问题,如果viewpager.setCurrentItem(2)或者其它值都不会出现该问题。

HpWens commented 3 years ago

遇到楼主一样的问题。

littlezan commented 3 years ago

用viewpager2吧

HpWens commented 3 years ago

刚测试 使用 viewpager2 也有同样的问题。。

littlezan commented 3 years ago

我记得使用viewpager2是没有这个问题的