KotlinCS 124 LogoJava

MP2: Course Activity

To wrap up MP2, we’ll add support for viewing details about a single course to our app. We’ll add a new activity that uses the support for retrieving course information we’ve already added to our API server and client.

MainActivity Course Clicked
MainActivity Course Clicked

As usual, you should be done with previous tests before proceeding. Specifically, you should be passing test0_CourseClassDesign, test1_ServerCourseRoute, and test2_ClientGetCourse. We’ll be using all of that functionality to wrap up MP2!

Our first step is to add the ability to handle clicks on summaries in our summary list. This is where we’ll launch our new CourseActivity, and so we’ll also have a chance to discuss how to launch an activity in Android.

https://www.youtube.com/watch?v=KVj1eKAxSxo

Note that, as described in the walkthrough above, to pass the test case here you need to add a String extra to the Intent with the key “summary” containing the summary that was clicked serialized to JSON. You should use the information and guidance about serialization we’ve provided in past lessons.

CourseActivity UI
CourseActivity UI

We’re almost there! At this point:

  1. Your server can provide course details via the /course/ route
  2. Your client can fetch those details using the getCourse method
  3. Your MainActivity can launch the CourseActivity and pass it details on the course to display

All that’s left is to finish our CourseActivity so that the details about the course are shown! Let’s see how to do that.

https://www.youtube.com/watch?v=mvkmsySXKv8

When you are done, your CourseActivity should display the title for the course—equivalent to the toString method for the Summary—and the course description. You don’t need two separate UI components to do this, but the two Strings should be separated by whitespace.

For this final bit of MP2 we’re providing a bit less explicit guidance, to give you a chance to spread your wings. You can do it! Refer to the code in the MainActivity for help, since there are great things to mimic there. Ask on the forum or tutoring site when you get stuck. Have fun!

Your Goal Today
Your Goal Today

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.

Right now your goal should be to

  1. modify your MainActivity so that it correctly generates an Intent when a course is clicked, which will pass test3_SummaryClickLaunch
  2. design your CourseActivity class so that it correctly displays the course description using the information provided by the Intent and the getCourse method you completed on your API client, which will pass test4_CourseView
  3. At that point you’ll be done with MP2!

If you get stuck, find us for help on the tutoring site or forum. If you have extra time after today’s lesson, you may want to move on and begin work on the next lesson, which also covers MP1.

MP2 Scores
MP2 Scores

˝