mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 14:29:08 +01:00
parent
4d8340a0c3
commit
963e125d64
@ -27,6 +27,8 @@ abstract class TrackService(val id: Int) {
|
||||
|
||||
abstract fun getStatusList(): List<Int>
|
||||
|
||||
abstract fun isCompletedStatus(index: Int): Boolean
|
||||
|
||||
abstract fun getStatus(status: Int): String
|
||||
|
||||
abstract fun getScoreList(): List<String>
|
||||
|
@ -38,6 +38,8 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
|
||||
|
||||
override fun getStatusList() = listOf(READING, PLANNING, COMPLETED, REPEATING, PAUSED, DROPPED)
|
||||
|
||||
override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED
|
||||
|
||||
override fun getStatus(status: Int): String = with(context) {
|
||||
when (status) {
|
||||
READING -> getString(R.string.reading)
|
||||
|
@ -76,6 +76,8 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
|
||||
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLANNING)
|
||||
}
|
||||
|
||||
override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED
|
||||
|
||||
override fun getStatus(status: Int): String = with(context) {
|
||||
when (status) {
|
||||
READING -> getString(R.string.reading)
|
||||
|
@ -44,6 +44,8 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
|
||||
return listOf(READING, PLAN_TO_READ, COMPLETED, ON_HOLD, DROPPED)
|
||||
}
|
||||
|
||||
override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED
|
||||
|
||||
override fun getStatus(status: Int): String = with(context) {
|
||||
when (status) {
|
||||
READING -> getString(R.string.currently_reading)
|
||||
|
@ -36,6 +36,8 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
||||
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ)
|
||||
}
|
||||
|
||||
override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED
|
||||
|
||||
override fun getScoreList(): List<String> {
|
||||
return IntRange(0, 10).map(Int::toString)
|
||||
}
|
||||
@ -121,7 +123,8 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
|
||||
networkService.cookieManager.remove(BASE_URL.toHttpUrlOrNull()!!)
|
||||
}
|
||||
|
||||
private val isAuthorized = super.isLogged && getCSRF().isNotEmpty() && checkCookies()
|
||||
private val isAuthorized: Boolean
|
||||
get() = super.isLogged && getCSRF().isNotEmpty() && checkCookies()
|
||||
|
||||
fun getCSRF(): String = preferences.trackToken(this).getOrDefault()
|
||||
|
||||
|
@ -27,6 +27,8 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
|
||||
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLANNING, REPEATING)
|
||||
}
|
||||
|
||||
override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED
|
||||
|
||||
override fun getStatus(status: Int): String = with(context) {
|
||||
when (status) {
|
||||
READING -> getString(R.string.reading)
|
||||
|
@ -821,6 +821,8 @@ class MangaDetailsPresenter(
|
||||
fun setStatus(item: TrackItem, index: Int) {
|
||||
val track = item.track!!
|
||||
track.status = item.service.getStatusList()[index]
|
||||
if (item.service.isCompletedStatus(index) && track.total_chapters > 0)
|
||||
track.last_chapter_read = track.total_chapters
|
||||
updateRemote(track, item.service)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user