Let's wrap up our work on allowing a user to add their favorite place to the map! In this lesson, we'll discuss how to complete the UI work required to bring this new feature to fruition. Let's do it!
At this point our
AddPlaceActivity.java is blank.
Let's fix that, load the layout that we've provided for this activity, and discuss where to define the unique ID for this client.
Next, let's get some practice integrating our layout with our activity. Specifically, we'll add an action to the Cancel button allowing the user to return to the map overview without adding a favorite place—for example, if they mis-clicked on the map, or changed their mind about where their favorite place is.
This will allow us to establish a general pattern for the rest of this part of the project, in demonstrating how to create links between the components that define the layout and the functionality provided in our Java code.
To wrap up, let's discuss what's left to do and create a plan in comments. Note that we are expecting you to do a bit of work on your own to complete the checkpoint! But we'll provide some hints that should point you in the right direction.
To describe the desired behavior of this activity in a bit more detail.
When the save button is pressed, a new favorite place on the map should be created, with the latitute and longitude passed to the
AddPlaceActivity when it was launched, a description provided by the user in the appropriate text box, and the ID defined in
After the call to create the favorite place completes successfully, the
AddPlaceActivity should return to the
MainActivity so that the user can view the updated map.
There may be other functionality that you want to add to the
AddPlaceActivity to make it more usable—for example, provide a default "Enter your description here..." text in the description input, not create new favorite places if the description is empty, or show an error message if the call to create the favorite place fails.
You should be able to add some of these additional features and still pass the test suite.
However, the test suite does not test these optional capabilities.
As a reminder, on lessons where we focus on the machine project we will not assign a homework problem! However, the lesson will usually focus on helping you complete a particular part of the MP test suite, and so we encourage you to spend time on that in lieu of a homework problem.
Need more practice? Head over to the practice page.