mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-29 09:39:03 +03:00
make episode switch buttons unclickable
This commit is contained in:
parent
1391ce0703
commit
a8477019e0
2 changed files with 36 additions and 17 deletions
|
@ -276,6 +276,7 @@ class PlayerActivity :
|
|||
player.addObserver(this)
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler { _, throwable ->
|
||||
launchUI { toast(throwable.message) }
|
||||
logcat(LogPriority.ERROR, throwable)
|
||||
finish()
|
||||
}
|
||||
|
@ -633,10 +634,16 @@ class PlayerActivity :
|
|||
val plCount = presenter.episodeList.size
|
||||
val plPos = presenter.getCurrentEpisodeIndex()
|
||||
|
||||
val g = ContextCompat.getColor(this, R.color.tint_disabled)
|
||||
val w = ContextCompat.getColor(this, R.color.tint_normal)
|
||||
binding.playerControls.binding.prevBtn.imageTintList = ColorStateList.valueOf(if (plPos == 0) g else w)
|
||||
binding.playerControls.binding.nextBtn.imageTintList = ColorStateList.valueOf(if (plPos == plCount - 1) g else w)
|
||||
val grey = ContextCompat.getColor(this, R.color.tint_disabled)
|
||||
val white = ContextCompat.getColor(this, R.color.tint_normal)
|
||||
with(binding.playerControls.binding.prevBtn) {
|
||||
this.imageTintList = ColorStateList.valueOf(if (plPos == 0) grey else white)
|
||||
this.isClickable = plPos != 0
|
||||
}
|
||||
with(binding.playerControls.binding.nextBtn) {
|
||||
this.imageTintList = ColorStateList.valueOf(if (plPos == plCount - 1) grey else white)
|
||||
this.isClickable = plPos != plCount - 1
|
||||
}
|
||||
}
|
||||
|
||||
private fun updatePlaybackStatus(paused: Boolean) {
|
||||
|
|
|
@ -164,17 +164,21 @@ class PlayerPresenter(
|
|||
currentEpisode = episodeList.first { initialEpisodeId == it.id }
|
||||
launchIO {
|
||||
try {
|
||||
val currentEpisode = currentEpisode ?: throw Exception("bruh")
|
||||
val currentEpisode = currentEpisode ?: throw Exception("No episode loaded.")
|
||||
EpisodeLoader.getLinks(currentEpisode, anime, source!!)
|
||||
.subscribeFirst(
|
||||
{ activity, it ->
|
||||
currentVideoList = it
|
||||
activity.setVideoList(it)
|
||||
if (it.isNotEmpty()) {
|
||||
activity.setVideoList(it)
|
||||
} else {
|
||||
activity.setInitialEpisodeError(Exception("Video list is empty."))
|
||||
}
|
||||
},
|
||||
PlayerActivity::setInitialEpisodeError,
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e) { e.message ?: "error getting links" }
|
||||
logcat(LogPriority.ERROR, e) { e.message ?: "Error getting links." }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +190,7 @@ class PlayerPresenter(
|
|||
}
|
||||
|
||||
fun nextEpisode(callback: () -> Unit): String? {
|
||||
val anime = anime ?: return "Invalid"
|
||||
val anime = anime ?: return null
|
||||
val source = sourceManager.getOrStub(anime.source)
|
||||
|
||||
val index = getCurrentEpisodeIndex()
|
||||
|
@ -194,25 +198,29 @@ class PlayerPresenter(
|
|||
currentEpisode = episodeList[index + 1]
|
||||
launchIO {
|
||||
try {
|
||||
val currentEpisode = currentEpisode ?: throw Exception("bruh")
|
||||
val currentEpisode = currentEpisode ?: throw Exception("No episode loaded.")
|
||||
EpisodeLoader.getLinks(currentEpisode, anime, source)
|
||||
.subscribeFirst(
|
||||
{ activity, it ->
|
||||
currentVideoList = it
|
||||
activity.setVideoList(it)
|
||||
callback()
|
||||
if (it.isNotEmpty()) {
|
||||
activity.setVideoList(it)
|
||||
callback()
|
||||
} else {
|
||||
activity.setInitialEpisodeError(Exception("Video list is empty."))
|
||||
}
|
||||
},
|
||||
PlayerActivity::setInitialEpisodeError,
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e) { e.message ?: "error getting links" }
|
||||
logcat(LogPriority.ERROR, e) { e.message ?: "Error getting links." }
|
||||
}
|
||||
}
|
||||
return anime.title + " - " + episodeList[index + 1].name
|
||||
}
|
||||
|
||||
fun previousEpisode(callback: () -> Unit): String? {
|
||||
val anime = anime ?: return "Invalid"
|
||||
val anime = anime ?: return null
|
||||
val source = sourceManager.getOrStub(anime.source)
|
||||
|
||||
val index = getCurrentEpisodeIndex()
|
||||
|
@ -220,18 +228,22 @@ class PlayerPresenter(
|
|||
currentEpisode = episodeList[index - 1]
|
||||
launchIO {
|
||||
try {
|
||||
val currentEpisode = currentEpisode ?: throw Exception("bruh")
|
||||
val currentEpisode = currentEpisode ?: throw Exception("No episode loaded.")
|
||||
EpisodeLoader.getLinks(currentEpisode, anime, source)
|
||||
.subscribeFirst(
|
||||
{ activity, it ->
|
||||
currentVideoList = it
|
||||
activity.setVideoList(it)
|
||||
callback()
|
||||
if (it.isNotEmpty()) {
|
||||
activity.setVideoList(it)
|
||||
callback()
|
||||
} else {
|
||||
activity.setInitialEpisodeError(Exception("Video list is empty."))
|
||||
}
|
||||
},
|
||||
PlayerActivity::setInitialEpisodeError,
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e) { e.message ?: "error getting links" }
|
||||
logcat(LogPriority.ERROR, e) { e.message ?: "Error getting links." }
|
||||
}
|
||||
}
|
||||
return anime.title + " - " + episodeList[index - 1].name
|
||||
|
|
Loading…
Reference in a new issue