Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@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.
il...@google.com <il...@google.com>
il...@google.com <il...@google.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
Description
Version used: 1.0.0-alpha07
Devices/Android versions reproduced on:
ActivityNavigator only supports string arguments for filling in the data pattern. It should at least use toString() on any type of argument.