I am working on an Android app using Java, and I have a RecyclerView
displaying a list of songs. When a song is selected, it starts playing, and the app navigates to a player Activity
. After returning to the original fragment with the song list, I want to highlight the currently playing song and display a playing animation (e.g., a GIF) next to it. Additionally, if another song is selected and starts playing, only the newly selected song should be highlighted, and the previous one should return to its default state.
I store the currently playing song's details in a SessionManager
.
In my adapter's onBindViewHolder
method, I check if the song is the currently playing one and update the UI accordingly.
In the fragment's onResume
method, I call notifyDataSetChanged()
on the adapter to refresh the UI.
I am expecting if i change the songs anywhere in the app like from notification or miniplayer the in that fragment song highlight is also change for current time.
You can create a list and pass in player activity then check the current song index if matches then highlight the song on the current position. You also need to update your Adapter every second for current song identification. I hope you get the help from this!