From 674699aeabd831406de031449275e692bd7ba57c Mon Sep 17 00:00:00 2001 From: cd16b Date: Tue, 23 Jan 2024 09:58:26 +0100 Subject: [PATCH] fix code --- .../viewmodels/PlayerActivityViewModel.kt | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/player/video/src/main/java/dev/jdtech/jellyfin/viewmodels/PlayerActivityViewModel.kt b/player/video/src/main/java/dev/jdtech/jellyfin/viewmodels/PlayerActivityViewModel.kt index 64329cae..5d95532b 100644 --- a/player/video/src/main/java/dev/jdtech/jellyfin/viewmodels/PlayerActivityViewModel.kt +++ b/player/video/src/main/java/dev/jdtech/jellyfin/viewmodels/PlayerActivityViewModel.kt @@ -253,22 +253,26 @@ constructor( if (player.currentMediaItem != null && player.currentMediaItem!!.mediaId.isNotEmpty()) { val itemId = UUID.fromString(player.currentMediaItem!!.mediaId) val seconds = player.currentPosition / 1000.0 - intros[itemId]?.let { intro -> - if (seconds > intro.showSkipPromptAt && seconds < intro.hideSkipPromptAt) { - _uiState.update { it.copy(currentIntro = intro) } - return@let + if (intros.isNotEmpty()) { + intros[itemId]?.let { intro -> + if (seconds > intro.showSkipPromptAt && seconds < intro.hideSkipPromptAt) { + _uiState.update { it.copy(currentIntro = intro) } + return@let + } + _uiState.update { it.copy(currentIntro = null) } } - _uiState.update { it.copy(currentIntro = null) } } - credits[itemId]?.let { credit -> - if (seconds > credit.showSkipPromptAt && seconds < credit.hideSkipPromptAt) { - _uiState.update { it.copy(currentCredit = credit) } - return@let + if (credits.isNotEmpty()) { + credits[itemId]?.let { credit -> + if (seconds > credit.showSkipPromptAt && seconds < credit.hideSkipPromptAt) { + _uiState.update { it.copy(currentCredit = credit) } + return@let + } + _uiState.update { it.copy(currentCredit = null) } } - _uiState.update { it.copy(currentCredit = null) } } - handler.postDelayed(this, 1000L) } + handler.postDelayed(this, 1000L) } } handler.post(playbackProgressRunnable)