Fixed
Status Update
Comments
lp...@google.com <lp...@google.com> #2
What are you trying to do? Can you include a sample project that reproduces your issue?
lp...@google.com <lp...@google.com> #3
I use a custom Dialog navigator that doesn't allow 2 dialogs open at the same time. I'll create a sample project in the next few days
ma...@gmail.com <ma...@gmail.com> #4
Sample project here: https://github.com/rubensousa/CustomNavigatorSample
Crash on 2.3.2:
Caused by: java.lang.ClassCastException: com.navigation.sample.SingleDialogNavigator cannot be cast to androidx.navigation.fragment.DialogFragmentNavigator
at androidx.navigation.fragment.NavHostFragment.onAttachFragment(NavHostFragment.java:293)
Expected behavior: no crash as in 2.3.1
Crash on 2.3.2:
Caused by: java.lang.ClassCastException: com.navigation.sample.SingleDialogNavigator cannot be cast to androidx.navigation.fragment.DialogFragmentNavigator
at androidx.navigation.fragment.NavHostFragment.onAttachFragment(NavHostFragment.java:293)
Expected behavior: no crash as in 2.3.1
jb...@google.com <jb...@google.com> #5
Any update on this? This is preventing us from updating to newer releases
ma...@gmail.com <ma...@gmail.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit ffe68e0a3be1da83217fadd4e40c5abad4f72b82
Author: Ian Lake <ilake@google.com>
Date: Tue Apr 06 12:40:35 2021
Use FragmentOnAttachListener in DialogFragmentNavigator
Rather than having the NavHostFragment
explicitly look for the DialogFragmentNavigator
to forward the fragment attach callback,
have DialogFragmentNavigator use the
Fragment 1.3 FragmentOnAttachListener API
to fully contain that logic within the
DialogFragmentNavigator.
Relnote: "`NavHostFragment` now supports custom
Navigators that use the same `@Navigator.Name(\"dialog\")`
as the default `DialogFragmentNavigator`."
Test: existing tests still pass
BUG: 175979140
Change-Id: Ib1c2cc38e7a621d133be1f4c3692e62913450dda
M navigation/navigation-fragment/api/public_plus_experimental_current.txt
M navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/DialogFragmentNavigator.kt
M navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.kt
https://android-review.googlesource.com/1665820
Branch: androidx-main
commit ffe68e0a3be1da83217fadd4e40c5abad4f72b82
Author: Ian Lake <ilake@google.com>
Date: Tue Apr 06 12:40:35 2021
Use FragmentOnAttachListener in DialogFragmentNavigator
Rather than having the NavHostFragment
explicitly look for the DialogFragmentNavigator
to forward the fragment attach callback,
have DialogFragmentNavigator use the
Fragment 1.3 FragmentOnAttachListener API
to fully contain that logic within the
DialogFragmentNavigator.
Relnote: "`NavHostFragment` now supports custom
Navigators that use the same `@Navigator.Name(\"dialog\")`
as the default `DialogFragmentNavigator`."
Test: existing tests still pass
BUG: 175979140
Change-Id: Ib1c2cc38e7a621d133be1f4c3692e62913450dda
M navigation/navigation-fragment/api/public_plus_experimental_current.txt
M navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/DialogFragmentNavigator.kt
M navigation/navigation-fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.kt
Description
PreferenceFragmentCompat sets this adapter (PreferenceGroupAdapter), which implicitly registers an observer. PreferenceFragmentCompat never sets the adapter to null when the view is destroyed, so the observer keeps references to the RecyclerView and doesn't get gc'ed.
I've worked around this by explicitly setting the adapter to null in an override of onDestroyView, but since my component doesn't explicitly have ownership of the list handling, I'd argue that PreferenceFragmentCompat should do this cleanup.
It would be solved by setting the RecyclerView adapter to null in the fragment's onDestroyView.
Here's a memory dump.