clean code

This commit is contained in:
cd16b 2024-01-22 22:59:04 +01:00
parent 2b9831af56
commit f9454029f7

View file

@ -248,41 +248,31 @@ constructor(
handler.postDelayed(this, 5000L)
}
}
val introCheckRunnable = object : Runnable {
val skipCheckRunnable = object : Runnable {
override fun run() {
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 ->
val seconds = player.currentPosition / 1000.0
if (seconds > intro.showSkipPromptAt && seconds < intro.hideSkipPromptAt) {
_uiState.update { it.copy(currentIntro = intro) }
return@let
}
_uiState.update { it.copy(currentIntro = null) }
}
handler.postDelayed(this, 1000L)
}
}
}
val creditCheckRunnable = object : Runnable {
override fun run() {
if (player.currentMediaItem != null && player.currentMediaItem!!.mediaId.isNotEmpty()) {
val itemId = UUID.fromString(player.currentMediaItem!!.mediaId)
credits[itemId]?.let { credit ->
val seconds = player.currentPosition / 1000.0
if (seconds > credit.showSkipPromptAt && seconds < credit.hideSkipPromptAt) {
_uiState.update { it.copy(currentCredit = credit) }
return@let
}
_uiState.update { it.copy(currentCredit = null) }
}
handler.postDelayed(this, 1000L)
}
handler.postDelayed(this, 1000L)
}
}
handler.post(playbackProgressRunnable)
if (intros.isNotEmpty()) handler.post(introCheckRunnable)
if (credits.isNotEmpty()) handler.post(creditCheckRunnable)
if (intros.isNotEmpty() || credits.isNotEmpty()) handler.post(skipCheckRunnable)
}
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {