Manga Rock fixes (#279)

* Manga Rock: tristate completed filter, sort chapters in descending order

* Bump Manga Rock version suffix
This commit is contained in:
Eugene 2018-04-08 07:39:11 -04:00 committed by Carlos
parent 72f3a09d21
commit 3ab2c25f48
2 changed files with 10 additions and 9 deletions

View File

@ -5,8 +5,8 @@ ext {
appName = 'Tachiyomi: Manga Rock' appName = 'Tachiyomi: Manga Rock'
pkgNameSuffix = "en.mangarock" pkgNameSuffix = "en.mangarock"
extClass = '.MangaRock' extClass = '.MangaRock'
extVersionCode = 2 extVersionCode = 3
extVersionSuffix = 1 extVersionSuffix = 2
libVersion = '1.0' libVersion = '1.0'
} }

View File

@ -68,7 +68,11 @@ class MangaRock : HttpSource() {
filters.forEach { filter -> filters.forEach { filter ->
when (filter) { when (filter) {
is StatusFilter -> { is StatusFilter -> {
status = filter.toUriPart() status = when (filter.state) {
Filter.TriState.STATE_INCLUDE -> "completed"
Filter.TriState.STATE_EXCLUDE -> "ongoing"
else -> "all"
}
} }
is RankFilter -> { is RankFilter -> {
rank = filter.toUriPart() rank = filter.toUriPart()
@ -177,7 +181,8 @@ class MangaRock : HttpSource() {
val obj = JSONObject(response.body()!!.string()).getJSONObject("data") val obj = JSONObject(response.body()!!.string()).getJSONObject("data")
val chapters = ArrayList<SChapter>() val chapters = ArrayList<SChapter>()
val arr = obj.getJSONArray("chapters") val arr = obj.getJSONArray("chapters")
for (i in 0 until arr.length()) { // Iterate backwards to match website's sorting
for (i in arr.length() - 1 downTo 0) {
val chapter = arr.getJSONObject(i) val chapter = arr.getJSONObject(i)
chapters.add(SChapter.create().apply { chapters.add(SChapter.create().apply {
name = chapter.getString("name") name = chapter.getString("name")
@ -236,11 +241,7 @@ class MangaRock : HttpSource() {
return buffer return buffer
} }
private class StatusFilter : UriPartFilter("Completed", arrayOf( private class StatusFilter : Filter.TriState("Completed")
Pair("All", "all"),
Pair("Completed", "completed"),
Pair("Ongoing", "ongoing")
))
private class RankFilter : UriPartFilter("Rank", arrayOf( private class RankFilter : UriPartFilter("Rank", arrayOf(
Pair("All", "all"), Pair("All", "all"),