From b35b3b2df21a9aad3e1b59a8d6d6d01cf3b7de88 Mon Sep 17 00:00:00 2001 From: vfsfitvnm Date: Thu, 15 Sep 2022 19:01:44 +0200 Subject: [PATCH] Fix exoplayer crash (regression) --- .../kotlin/it/vfsfitvnm/vimusic/ui/views/player/Controls.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/views/player/Controls.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/views/player/Controls.kt index 1a23b53..efd1c89 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/views/player/Controls.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/views/player/Controls.kt @@ -182,10 +182,11 @@ fun Controls( colorFilter = ColorFilter.tint(colorPalette.favoritesIcon), modifier = Modifier .clickable { + val currentMediaItem = binder.player.currentMediaItem query { if (Database.like(mediaId, if (likedAt == null) System.currentTimeMillis() else null) == 0) { - binder.player.currentMediaItem?.takeIf { it.mediaId == mediaId }?.let { mediaItem -> - Database.insert(mediaItem, Song::toggleLike) + currentMediaItem?.takeIf { it.mediaId == mediaId }?.let { + Database.insert(currentMediaItem, Song::toggleLike) } } }