Erik
01/24/2020, 6:31 PMandroidx.fragment artifacts v1.2.0 and up, AND
- If you observe LiveData in fragments, AND
- If that fragment does inflate a view in onCreateView AND
- If that view is not null
THEN use viewLifecycleOwner to observe live data.
OTHERWISE use the fragment itself, which is a LifecycleOwner, to observe live data.
Is this correct?Erik
01/24/2020, 6:33 PMandroidx.fragment v1.2.0, but it doesn't seem to work on my (and a colleague's) machine.Anastasia Finogenova
01/24/2020, 8:22 PMAdam Powell
01/24/2020, 8:30 PMviewLifecycleOwner, if it does not, use the fragment itselfErik
01/24/2020, 8:38 PMErik
01/24/2020, 8:39 PMLifecycleOwner that observes, then observe in onCreate.Adam Powell
01/24/2020, 8:41 PMinit block too if you felt so inclined.Adam Powell
01/24/2020, 8:42 PMviewLifecycleOwner does matter though, as it gets recreated if the views are recreatedAdam Powell
01/24/2020, 8:43 PMErik
01/24/2020, 8:43 PMAdam Powell
01/24/2020, 8:44 PMErik
01/24/2020, 8:44 PMviewLifecycleObserver because it modifies a menu's views on observationsErik
01/24/2020, 8:44 PMAdam Powell
01/24/2020, 8:45 PMErik
01/24/2020, 8:45 PM