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)
|
player.addObserver(this)
|
||||||
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler { _, throwable ->
|
Thread.setDefaultUncaughtExceptionHandler { _, throwable ->
|
||||||
|
launchUI { toast(throwable.message) }
|
||||||
logcat(LogPriority.ERROR, throwable)
|
logcat(LogPriority.ERROR, throwable)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
@ -633,10 +634,16 @@ class PlayerActivity :
|
||||||
val plCount = presenter.episodeList.size
|
val plCount = presenter.episodeList.size
|
||||||
val plPos = presenter.getCurrentEpisodeIndex()
|
val plPos = presenter.getCurrentEpisodeIndex()
|
||||||
|
|
||||||
val g = ContextCompat.getColor(this, R.color.tint_disabled)
|
val grey = ContextCompat.getColor(this, R.color.tint_disabled)
|
||||||
val w = ContextCompat.getColor(this, R.color.tint_normal)
|
val white = ContextCompat.getColor(this, R.color.tint_normal)
|
||||||
binding.playerControls.binding.prevBtn.imageTintList = ColorStateList.valueOf(if (plPos == 0) g else w)
|
with(binding.playerControls.binding.prevBtn) {
|
||||||
binding.playerControls.binding.nextBtn.imageTintList = ColorStateList.valueOf(if (plPos == plCount - 1) g else w)
|
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) {
|
private fun updatePlaybackStatus(paused: Boolean) {
|
||||||
|
|
|
@ -164,17 +164,21 @@ class PlayerPresenter(
|
||||||
currentEpisode = episodeList.first { initialEpisodeId == it.id }
|
currentEpisode = episodeList.first { initialEpisodeId == it.id }
|
||||||
launchIO {
|
launchIO {
|
||||||
try {
|
try {
|
||||||
val currentEpisode = currentEpisode ?: throw Exception("bruh")
|
val currentEpisode = currentEpisode ?: throw Exception("No episode loaded.")
|
||||||
EpisodeLoader.getLinks(currentEpisode, anime, source!!)
|
EpisodeLoader.getLinks(currentEpisode, anime, source!!)
|
||||||
.subscribeFirst(
|
.subscribeFirst(
|
||||||
{ activity, it ->
|
{ activity, it ->
|
||||||
currentVideoList = it
|
currentVideoList = it
|
||||||
activity.setVideoList(it)
|
if (it.isNotEmpty()) {
|
||||||
|
activity.setVideoList(it)
|
||||||
|
} else {
|
||||||
|
activity.setInitialEpisodeError(Exception("Video list is empty."))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
PlayerActivity::setInitialEpisodeError,
|
PlayerActivity::setInitialEpisodeError,
|
||||||
)
|
)
|
||||||
} catch (e: Exception) {
|
} 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? {
|
fun nextEpisode(callback: () -> Unit): String? {
|
||||||
val anime = anime ?: return "Invalid"
|
val anime = anime ?: return null
|
||||||
val source = sourceManager.getOrStub(anime.source)
|
val source = sourceManager.getOrStub(anime.source)
|
||||||
|
|
||||||
val index = getCurrentEpisodeIndex()
|
val index = getCurrentEpisodeIndex()
|
||||||
|
@ -194,25 +198,29 @@ class PlayerPresenter(
|
||||||
currentEpisode = episodeList[index + 1]
|
currentEpisode = episodeList[index + 1]
|
||||||
launchIO {
|
launchIO {
|
||||||
try {
|
try {
|
||||||
val currentEpisode = currentEpisode ?: throw Exception("bruh")
|
val currentEpisode = currentEpisode ?: throw Exception("No episode loaded.")
|
||||||
EpisodeLoader.getLinks(currentEpisode, anime, source)
|
EpisodeLoader.getLinks(currentEpisode, anime, source)
|
||||||
.subscribeFirst(
|
.subscribeFirst(
|
||||||
{ activity, it ->
|
{ activity, it ->
|
||||||
currentVideoList = it
|
currentVideoList = it
|
||||||
activity.setVideoList(it)
|
if (it.isNotEmpty()) {
|
||||||
callback()
|
activity.setVideoList(it)
|
||||||
|
callback()
|
||||||
|
} else {
|
||||||
|
activity.setInitialEpisodeError(Exception("Video list is empty."))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
PlayerActivity::setInitialEpisodeError,
|
PlayerActivity::setInitialEpisodeError,
|
||||||
)
|
)
|
||||||
} catch (e: Exception) {
|
} 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
|
return anime.title + " - " + episodeList[index + 1].name
|
||||||
}
|
}
|
||||||
|
|
||||||
fun previousEpisode(callback: () -> Unit): String? {
|
fun previousEpisode(callback: () -> Unit): String? {
|
||||||
val anime = anime ?: return "Invalid"
|
val anime = anime ?: return null
|
||||||
val source = sourceManager.getOrStub(anime.source)
|
val source = sourceManager.getOrStub(anime.source)
|
||||||
|
|
||||||
val index = getCurrentEpisodeIndex()
|
val index = getCurrentEpisodeIndex()
|
||||||
|
@ -220,18 +228,22 @@ class PlayerPresenter(
|
||||||
currentEpisode = episodeList[index - 1]
|
currentEpisode = episodeList[index - 1]
|
||||||
launchIO {
|
launchIO {
|
||||||
try {
|
try {
|
||||||
val currentEpisode = currentEpisode ?: throw Exception("bruh")
|
val currentEpisode = currentEpisode ?: throw Exception("No episode loaded.")
|
||||||
EpisodeLoader.getLinks(currentEpisode, anime, source)
|
EpisodeLoader.getLinks(currentEpisode, anime, source)
|
||||||
.subscribeFirst(
|
.subscribeFirst(
|
||||||
{ activity, it ->
|
{ activity, it ->
|
||||||
currentVideoList = it
|
currentVideoList = it
|
||||||
activity.setVideoList(it)
|
if (it.isNotEmpty()) {
|
||||||
callback()
|
activity.setVideoList(it)
|
||||||
|
callback()
|
||||||
|
} else {
|
||||||
|
activity.setInitialEpisodeError(Exception("Video list is empty."))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
PlayerActivity::setInitialEpisodeError,
|
PlayerActivity::setInitialEpisodeError,
|
||||||
)
|
)
|
||||||
} catch (e: Exception) {
|
} 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
|
return anime.title + " - " + episodeList[index - 1].name
|
||||||
|
|
Loading…
Reference in a new issue