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