Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight the current song on the album detail view #133

Merged
merged 5 commits into from
Sep 6, 2023

Conversation

rivaldi8
Copy link
Contributor

Until now, when playing an album, there was no way to view on the album detail view which song was playing. With these changes, now the current playing song is highlighted with a light blue background, like in the queue list. This way it's easier for the user to find the current point in the album.

Comment on lines 74 to 88

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false

other as Song

if (id != other.id) return false

return true
}

override fun hashCode(): Int {
return id.hashCode()
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to override the default behaviour of equals/hashcode here, as a convenience for comparing Song id's.

1.) This means that Song no longer behaves like a regular data class, which could be confusing / lead to unexpected behaviour
2.) I'm not sure if we're relying on the existing equality contract in other places, which could be broken by this change
3.) It's easy to just compare song.id == otherSong.id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit overwhelmed when a wrote that, so I don't think I noticed it was a data class. Anyway, I didn't remember about the data classes having already a proper equals ;-)

Fixed in 3a82613.

timusus and others added 3 commits August 21, 2023 21:26
Data classes already implement equals with the constructor fields, so
it's better not to override it without a good reason.
getCurrentSong()?.let {
view?.onCurrentSongChanged(it)
getCurrentSong()?.let { currentSong ->
view?.setData([email protected], currentSong)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity. Why is the qualifier needed in [email protected]? I've tried and it seems to work without it.

By the way, nice work! These changes make it much simpler. Thanks!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this@ is not needed, that looks like a copy paste error :D

@timusus timusus merged commit 10a3391 into timusus:main Sep 6, 2023
@rivaldi8 rivaldi8 deleted the highlight-current-album-song branch September 7, 2023 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants