Lecture 4 & HW 4: RecyclerViews

Lecture: Google Slides, YouTube

Lecture Demo Code:

Lec4Demo.zip
107KB
Binary
10/17/22 - Lecture 4 Demo for RecyclerViews

Discussion: Google Slides, YouTube

Demo4True.zip
108KB
Binary
10/25/23 - New demo with notifyItemChanged example.

Homework: Spotify Playlist

Objectives

Your goal is to recreate a simple version of Spotify's playlist view using RecyclerView and topics learned from previous weeks. We'll provide some guidelines below, but you will have the freedom to design the UI how you'll like!

Requirements:

1. Create an activity (ie. MainActivity) that has a RecyclerView that contains at least 10 different songs. Each cell in the RecyclerView must include an image, song name, artist, and album, and the cell must be built from a custom layout. You also must use a model to represent the information in each cell. Be clever with your models, especially with your image, to make it easier for your Adapter to use.
2. Clicking on a cell should open a new activity (ie. SongDetailActivity.kt) that displays the song's image, name, artist, and album.
3. In SongDetailActivity, there should be a save button and a way for the user to edit the song name, artist, and album. When the user clicks the save button, the song title should change to the new one, and the user should be redirected back to MainActivity. The list in MainActivity should also reflect this change.

Challenge Problems

These are optional challenge problems, and completing each successfully will earn you 1 extra point per problem. If you do attempt a challenge problem, make sure to include a README.txt that states which problem(s) you've attempted!

Share Songs (1 pt)

  • Create an Implicit Intent to share songs and the details of the song to other apps.

Search For Songs (2 pts)

  • Add a search bar at the top of the MainActivity in order to search for specific songs in the dataset.

Preferential Treatment (2 pts)

  • Add an icon (ie. heart) to each cell in MainActivity for liking a song. When the user clicks on this icon, the icon should change color or shape to represented "liked". The user should also be able to undo the like.
  • Add two filter buttons to the top of MainActivity, one for displaying all songs and one for displaying liked songs. Clicking on the buttons should filter the songs accordingly.

Dynamic Playlist (2 pts)

  • Add the ability for the user to add new songs and delete songs from the playlist. You have the freedom to design the user interactions for this feature -- just make sure to describe how it works in the README.txt.

Image Change (1 pt)

  • In SongDetailActivity, add the ability to change the song image with an image from the user's internal storage. You will need to ask for permission to access the user's storage as well as account for what happens if the user denies permissions.

References

For this assignment, you may need to figure out a few things on your own. Some classes that may be helpful for this assignment include:
For basic functionality:
  • RecyclerView
  • Intent
  • Bundle
For challenge problems:
  • PackageManager
  • ContextCompat
  • Manifest