Challenge: No Untitled Crimes

It is impossible to solve a crime if you do not know what crime occurred. But if you open the detail view for a crime, erase its title, and navigate back to the list view, you will save a crime with no name.

For this challenge, while in CrimeDetailFragment, prevent the user from navigating back to the list if the selected crime’s title is blank. Using an OnBackPressedCallback, you can override the default Back button behavior. If the title is blank, give the user a hint that they should provide a description of the crime.

Some developer documentation that will be helpful for this challenge is at developer.android.com/​guide/​navigation/​navigation-custom-back.

When using an OnBackPressedCallback, no navigation will happen unless you say so. So if there is a title, do not forget to use the NavController to pop off the CrimeDetailFragment from the navigation back stack.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset