Status Update
Comments
il...@google.com <il...@google.com> #2
The code referred to can be found in
override fun onResume() {
super.onResume()
if (navigated) {
findNavController().popBackStack()
return
}
var monitor = installViewModel.installMonitor
if (monitor == null) {
Log.i(TAG, "onResume: monitor is null, navigating")
navigate()
monitor = installViewModel.installMonitor
}
if (monitor != null) {
Log.i(TAG, "onResume: monitor is now not null, observing")
monitor.status.observe(this, StateObserver(monitor))
}
}
In case no monitor is attached during onResume
, we assign the installMonitor
from installViewModel
.
In either case a new StateObserver
is attached, which then observes status changes.
Once SplitSessionInstallState.INSTALLED
is observed, navigate()
is invoked from within StateObserver
.
Since navigate
is called in the StateObserver we might see multiple invocations by accident.
To alleviate this, we could create a Event
Alternatively, moving the calls from onResume
earlier in the lifecycle, e.g. onCreateView
could avoid unnecessary view creation in case navigation already has taken place, and could avoid multiple calls to the observed status.
ku...@gmail.com <ku...@gmail.com> #3
Branch: androidx-master-dev
commit 29c5aee2bf2685e3bc2a0e38ca0290408aa65b11
Author: Ben Weiss <benweiss@google.com>
Date: Tue Nov 03 14:41:39 2020
Move install monitor observation to onViewCreated
Bug: 169636207
Test: Existing tests pass
Change-Id: Ia0c1d903066a5206de5b862eb2a0d9e0899c690b
M navigation/navigation-dynamic-features-fragment/src/main/java/androidx/navigation/dynamicfeatures/fragment/ui/AbstractProgressFragment.kt
jb...@google.com <jb...@google.com> #4
This has been fixed and will be available in an upcoming Navigation 2.3.2 release.
jb...@google.com <jb...@google.com> #5
#4 I think this fix break the behavior of DefaultProgressFragment, it doesn't call super.onViewCreated() so that the installation won't execute.
Description
Component used: Fragment
Version used:
Devices/Android versions reproduced on: any
When using a `DialogFragment`, the `setOnCancelListener` and `setOnDismissListener` callback functions within the `onCreateDialog` function should not be used as the `DialogFragment` owns these callbacks. Instead the respective `onCancel` and `onDismiss` functions on `DialogFragment` can be overriden to achieve the desired effect.
While this is currently called out via a comment on the `onCreateDialog` function, a lint warning might better inform developers of this potential gotcha.