clean code
This commit is contained in:
parent
2b9831af56
commit
f9454029f7
1 changed files with 4 additions and 14 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue