Albirew/tachiyomi
Archivé
1
0
Bifurcation 0

Fix bug where status cannot be updated when all chapters have been read. (#2683)

Minor cleanup.
Cette révision appartient à :
MCAxiaz 2020-03-09 08:32:59 -07:00 révisé par GitHub
Parent fb00929ee9
révision 07e2bdac81
Aucune clé n'a été trouvée pour cette signature dans la base de données
ID de la clé GPG: 4AEE18F83AFDEB23
7 fichiers modifiés avec 41 ajouts et 40 suppressions

Voir le fichier

@ -31,6 +31,8 @@ abstract class TrackService(val id: Int) {
abstract fun getStatus(status: Int): String
abstract fun getCompletionStatus(): Int
abstract fun getScoreList(): List<String>
open fun indexToScore(index: Int): Float {

Voir le fichier

@ -72,6 +72,8 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
}
}
override fun getCompletionStatus(): Int = COMPLETED
override fun getScoreList(): List<String> {
return when (scorePreference.getOrDefault()) {
// 10 point
@ -133,9 +135,6 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) {
}
override fun update(track: Track): Observable<Track> {
if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) {
track.status = COMPLETED
}
// If user was using API v1 fetch library_id
if (track.library_id == null || track.library_id!! == 0L) {
return api.findLibManga(track, getUsername().toInt()).flatMap {

Voir le fichier

@ -34,9 +34,6 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
}
override fun update(track: Track): Observable<Track> {
if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) {
track.status = COMPLETED
}
return api.updateLibManga(track)
}
@ -99,6 +96,8 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) {
}
}
override fun getCompletionStatus(): Int = COMPLETED
override fun login(username: String, password: String) = login(password)
fun login(code: String): Completable {

Voir le fichier

@ -56,6 +56,8 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
}
}
override fun getCompletionStatus(): Int = COMPLETED
override fun getScoreList(): List<String> {
val df = DecimalFormat("0.#")
return listOf("0") + IntRange(2, 20).map { df.format(it / 2f) }
@ -75,10 +77,6 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) {
}
override fun update(track: Track): Observable<Track> {
if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) {
track.status = COMPLETED
}
return api.updateLibManga(track)
}

Voir le fichier

@ -38,6 +38,10 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
override fun getLogoColor() = Color.rgb(46, 81, 162)
override fun getStatusList(): List<Int> {
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ)
}
override fun getStatus(status: Int): String = with(context) {
when (status) {
READING -> getString(R.string.reading)
@ -49,9 +53,7 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
}
}
override fun getStatusList(): List<Int> {
return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ)
}
override fun getCompletionStatus(): Int = COMPLETED
override fun getScoreList(): List<String> {
return IntRange(0, 10).map(Int::toString)
@ -66,10 +68,6 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
}
override fun update(track: Track): Observable<Track> {
if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) {
track.status = COMPLETED
}
return api.updateLibManga(track)
}

Voir le fichier

@ -13,6 +13,26 @@ import uy.kohesive.injekt.injectLazy
class Shikimori(private val context: Context, id: Int) : TrackService(id) {
companion object {
const val READING = 1
const val COMPLETED = 2
const val ON_HOLD = 3
const val DROPPED = 4
const val PLANNING = 5
const val REPEATING = 6
const val DEFAULT_STATUS = READING
const val DEFAULT_SCORE = 0
}
override val name = "Shikimori"
private val gson: Gson by injectLazy()
private val interceptor by lazy { ShikimoriInterceptor(this, gson) }
private val api by lazy { ShikimoriApi(client, interceptor) }
override fun getScoreList(): List<String> {
return IntRange(0, 10).map(Int::toString)
}
@ -26,9 +46,6 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
}
override fun update(track: Track): Observable<Track> {
if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) {
track.status = COMPLETED
}
return api.updateLibManga(track, getUsername())
}
@ -63,26 +80,6 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
}
}
companion object {
const val READING = 1
const val COMPLETED = 2
const val ON_HOLD = 3
const val DROPPED = 4
const val PLANNING = 5
const val REPEATING = 6
const val DEFAULT_STATUS = READING
const val DEFAULT_SCORE = 0
}
override val name = "Shikimori"
private val gson: Gson by injectLazy()
private val interceptor by lazy { ShikimoriInterceptor(this, gson) }
private val api by lazy { ShikimoriApi(client, interceptor) }
override fun getLogo() = R.drawable.tracker_shikimori
override fun getLogoColor() = Color.rgb(40, 40, 40)
@ -103,6 +100,8 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) {
}
}
override fun getCompletionStatus(): Int = COMPLETED
override fun login(username: String, password: String) = login(password)
fun login(code: String): Completable {

Voir le fichier

@ -115,6 +115,9 @@ class TrackPresenter(
fun setStatus(item: TrackItem, index: Int) {
val track = item.track!!
track.status = item.service.getStatusList()[index]
if (track.status == item.service.getCompletionStatus() && track.total_chapters != 0) {
track.last_chapter_read = track.total_chapters
}
updateRemote(track, item.service)
}
@ -127,6 +130,9 @@ class TrackPresenter(
fun setLastChapterRead(item: TrackItem, chapterNumber: Int) {
val track = item.track!!
track.last_chapter_read = chapterNumber
if (track.total_chapters != 0 && track.last_chapter_read == track.total_chapters) {
track.status = item.service.getCompletionStatus()
}
updateRemote(track, item.service)
}
}