I’ve gone through the entire chapter, twice, and can’t see what I am missing. I am able to create an intent to view my contacts and I am able to select one. When I return to the CrimeFragment, onActivityResult()
is called and the selected contact is returned via the data. The button text is updated as appropriate and the call to the ViewModel to save the crime fires.
However, when the observer on CrimeFragment gets the crime the suspect is no longer set. Every other change to the crime saves and persists (title, date, time, solved, requiresPolice).
I even tried uninstalling the app so the database would be recreated incase my migration was incorrect, but the problem still persists.
Below is my log trace after selecting a contact and returning to CrimeFragment. Is there a step I am missing or a particular area that I should double check?
2019-09-27 20:29:01.112 9143-9143/criminalintentbnr4k D/CI4K.CrimeFragment: onCreate(Bundle?) called
2019-09-27 20:29:01.113 9143-9143/criminalintentbnr4k D/CI4K.CrimeFragment: args bundle crime ID 461f153a-34b8-43fe-aaf4-9696fae09dd7
2019-09-27 20:29:01.113 9143-9143/criminalintentbnr4k D/CI4K.CrimeDetailVM: loadCrime() called
2019-09-27 20:29:01.114 9143-9143/criminalintentbnr4k D/CI4K.CrimeListFragment: onAttach(Context) called
2019-09-27 20:29:01.114 9143-9143/criminalintentbnr4k D/CI4K.CrimeListFragment: onCreate(Bundle?) called
2019-09-27 20:29:01.114 9143-9143/criminalintentbnr4k D/CI4K.MainActivity: onCreate(Bundle?) called
2019-09-27 20:29:01.136 9143-9143/criminalintentbnr4k D/CI4K.CrimeFragment: onCreateView() called
2019-09-27 20:29:01.157 9143-9143/criminalintentbnr4k D/CI4K.CrimeFragment: onViewCreated() called
2019-09-27 20:29:01.157 9143-9143/criminalintentbnr4k D/CI4K.CrimeFragment: onActivityCreated() called
2019-09-27 20:29:01.164 9143-9143/criminalintentbnr4k D/CI4K.MainActivity: onStart() called
2019-09-27 20:29:01.167 9143-9143/criminalintentbnr4k D/CI4K.CrimeFragment: onActivityResult(2, -1, data) called
2019-09-27 20:29:01.172 9143-9143/criminalintentbnr4k D/CI4K.CrimeFragment: got suspect "Jim"
2019-09-27 20:29:01.172 9143-9143/criminalintentbnr4k D/CI4K.CrimeDetailVM: saveCrime() called
2019-09-27 20:29:01.173 9143-9143/criminalintentbnr4k D/CI4K.MainActivity: onResume() called
2019-09-27 20:29:01.174 9143-9143/criminalintentbnr4k D/CI4K.CrimeFragment: onResume() called
2019-09-27 20:29:01.179 9143-9143/criminalintentbnr4k D/CI4K.CrimeFragment: crime observed with suspect ""