Closed aritraroy closed 7 years ago
It works for me even if Fragments are inside ViewPager. Please check newly added example.
It doesn't work for me. I will explain you the situation.
I have an Activity which has a Fragment inside it. This Fragment contains a ViewPager containing 3 Fragments. I want to handle back pressed event in the Activity, parent Fragment and the Fragments inside the ViewPager.
But the issue is that I never get a callback in the child fragments. I think the problem is here,
List<Fragment> fragmentList = gActivity.getSupportFragmentManager().getFragments();
I have attached debugger and found this fragment list not containing any of my fragments inside the ViewPager and because of which the events are not dispatched to them.
Your idea of solving this problem is excellent. Hope to get some help on this issue.
Nested fragments are now supported. Should work right out of the box for you, just upgrade to version 0.2.0.
Thanks. Your enhancement works. But I had to put several null checks to prevent crashes which were happening because of this.
I would recommend you to improve the code and put the necessary null checks in place to make the library more robust.
I found only one place where NPE could happen. Is it already ok in version 0.2.1?
I actually had to fork the library to add the null checks myself as I was having several crashes and need to push an update to production as quick as I can.
I will put your 0.2.1 version and test it exhaustively later. Thanks a lot for the awesome support btw. 👍
Is your fork publicly available? Or can you make push-request with NPE checks?
I'm closing this ticket. Feel free to reopen, or open new one if you find any new issues.
It works for other fragments attached to an activity. But if there is a ViewPager and I want to handle back events inside the ViewPager fragments, then those fragments never get the event dispatched.