Update formatting

This commit is contained in:
tzugen 2023-12-04 10:55:00 +01:00
parent a63087ea61
commit 51e576a91e
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
4 changed files with 22 additions and 17 deletions

View File

@ -80,12 +80,7 @@ class TrackViewHolder(val view: View) :
private var rxBusSubscription: CompositeDisposable? = null
@Suppress("ComplexMethod")
fun setSong(
song: Track,
checkable: Boolean,
draggable: Boolean,
isSelected: Boolean = false
) {
fun setSong(song: Track, checkable: Boolean, draggable: Boolean, isSelected: Boolean = false) {
entry = song
val entryDescription = Util.readableEntryDescription(song)
@ -239,19 +234,23 @@ class TrackViewHolder(val view: View) :
3 -> R.drawable.rating_star_3
4 -> R.drawable.rating_star_4
5 -> R.drawable.rating_star_5
else -> { R.drawable.rating_star_0 }
else -> {
R.drawable.rating_star_0
}
}
val layers = if (starred) {
arrayOf(
ResourcesCompat.getDrawable(view.resources, ratingDrawable, null)!!,
ResourcesCompat.getDrawable(
view.resources, R.drawable.rating_heart_mini_overlay, null
)!!,
view.resources,
R.drawable.rating_heart_mini_overlay,
null
)!!
)
} else {
arrayOf(
ResourcesCompat.getDrawable(view.resources, ratingDrawable, null)!!,
ResourcesCompat.getDrawable(view.resources, ratingDrawable, null)!!
)
}

View File

@ -287,7 +287,9 @@ class PlayerFragment :
fullHeartDrawable = ResourcesCompat.getDrawable(resources, fullHeart, null)!!
setLayerDrawableColors(hollowHeartDrawable as LayerDrawable)
setLayerDrawableColors(
fullHeartDrawable as LayerDrawable, RM.attr.colorAccent, RM.attr.colorSurface
fullHeartDrawable as LayerDrawable,
RM.attr.colorAccent,
RM.attr.colorSurface
)
fiveStar1ImageView.setOnClickListener { setSongRating(1) }
@ -1278,8 +1280,11 @@ class PlayerFragment :
fiveStar4ImageView.setImageDrawable(getStarForRating(rating, 3))
fiveStar5ImageView.setImageDrawable(getStarForRating(rating, 4))
if (isHeartSet) heartRatingImageView.setImageDrawable(fullHeartDrawable)
else heartRatingImageView.setImageDrawable(hollowHeartDrawable)
if (isHeartSet) {
heartRatingImageView.setImageDrawable(fullHeartDrawable)
} else {
heartRatingImageView.setImageDrawable(hollowHeartDrawable)
}
}
private fun getStarForRating(rating: Int, position: Int): Drawable {
@ -1317,7 +1322,8 @@ class PlayerFragment :
RxBus.ratingSubmitter.onNext(
RatingUpdate(
currentSong!!.id, HeartRating(currentSong?.starred ?: false)
currentSong!!.id,
HeartRating(currentSong?.starred ?: false)
)
)
}

View File

@ -322,10 +322,11 @@ class MediaLibrarySessionCallback :
}
)
.setIconResId(
if (willHeart)
if (willHeart) {
R.drawable.rating_star_hollow
else
} else {
R.drawable.rating_star_full
}
)
.setSessionCommand(sessionCommand)
.setEnabled(true)

View File

@ -169,7 +169,6 @@ fun MediaItem.setRating(rating: Int) {
*/
@Suppress("ComplexMethod")
fun MediaItem.toTrack(cacheResult: Boolean = true): Track {
// Check Cache
val cachedTrack = MediaItemConverter.trackCache[mediaId]?.get()
if (cachedTrack != null) return cachedTrack