Gilles Braun
07/24/2019, 12:14 PMruialonso
07/24/2019, 12:28 PMonCreate
instead of onViewCreated
. Fragment lifecycle is different from Activity and doesn't die, so every time Fragment is shown again it will handle observable from viewmodel even if no updatesGilles Braun
07/24/2019, 12:35 PMonStart
. Trying to observe the viewmodel in onCreate
doesn't work as with the error IllegalStateException: Can't access the Fragment View's LifecycleOwner when getView() is null i.e., before onCreateView()
. As far as I can tell the problem is not with the fragment, as it receives the updates correctly. But the activity doesn'truialonso
07/24/2019, 12:41 PMGilles Braun
07/24/2019, 12:41 PMruialonso
07/24/2019, 12:41 PMGilles Braun
07/24/2019, 12:41 PMruialonso
07/24/2019, 12:42 PMGilles Braun
07/24/2019, 12:43 PMobserver called in fragment, people: 1
observer called in activity, people: 1
observer called in fragment, people: 2
observer called in fragment, people: 3
observer called in fragment, people: 4
observer called in fragment, people: 3
ruialonso
07/24/2019, 12:44 PMGilles Braun
07/24/2019, 12:44 PMruialonso
07/24/2019, 12:47 PMGilles Braun
07/24/2019, 12:48 PMruialonso
07/24/2019, 12:49 PMGilles Braun
07/24/2019, 12:49 PMruialonso
07/24/2019, 12:50 PMGilles Braun
07/24/2019, 12:56 PMViewModelProviders.of(getActivity()).get(..)
ruialonso
07/24/2019, 12:58 PMGilles Braun
07/24/2019, 12:59 PMGrygorii Shcherbiak
07/24/2019, 6:11 PMthis
pointers every time you hit a breakpoint in the LiveData observer and validate this