adam-codersgu / supernova

A Kotlin-based Android application that allows the user to play music from their device while custom animations fall over the album artwork of the currently playing song.
0 stars 0 forks source link

Reusability of RecyclerView updating code #28

Closed adam-codersgu closed 1 year ago

adam-codersgu commented 1 year ago

In AlbumFragment, I have added a way of updating the RecyclerView that could potentially be applied to other similar UIs e.g. artist song view, song view etc. Could potentially explore using an interface to prevent code duplication? Perhaps also other methods in the interface could be used for updating RecyclerViews that display other types of content e.g. Playlist objects or artist names. In which case, perhaps some kind of interface hierarchy could be used where abstract methods are implemented as required. Need to ensure that each adapter type can be accessed in a similar way though. For example, this could potentially be done by referencing each adapter based on its supertype RecyclerView.Adapter()

adam-codersgu commented 1 year ago

Important: Note any RecyclerView adapters that have a header element e.g. Album/Playlist views will need to have + 1 added to the index of any content updates.

The interface could have two variables: contentIndex and adapterIndex (which could have + 1 if needed)

adam-codersgu commented 1 year ago

Important: Also note that for the RecyclerView updates to be effective, onClickListeners need to be assigned in the ViewHolder rather than onBindViewHolder, as demonstrated in AlbumAdapter

adam-codersgu commented 1 year ago

Working on branch enhancement/recycler_view_interface_inheritance

adam-codersgu commented 1 year ago

Completed and merged https://github.com/adam-codersgu/supernova/pull/44