From 3ab2c25f486cf833a4bee1781dac649d816fcf69 Mon Sep 17 00:00:00 2001 From: Eugene Date: Sun, 8 Apr 2018 07:39:11 -0400 Subject: [PATCH] Manga Rock fixes (#279) * Manga Rock: tristate completed filter, sort chapters in descending order * Bump Manga Rock version suffix --- src/en/mangarock/build.gradle | 4 ++-- .../tachiyomi/extension/en/mangarock/MangaRock.kt | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/en/mangarock/build.gradle b/src/en/mangarock/build.gradle index cef241da4..83eb5fd46 100644 --- a/src/en/mangarock/build.gradle +++ b/src/en/mangarock/build.gradle @@ -5,8 +5,8 @@ ext { appName = 'Tachiyomi: Manga Rock' pkgNameSuffix = "en.mangarock" extClass = '.MangaRock' - extVersionCode = 2 - extVersionSuffix = 1 + extVersionCode = 3 + extVersionSuffix = 2 libVersion = '1.0' } diff --git a/src/en/mangarock/src/eu/kanade/tachiyomi/extension/en/mangarock/MangaRock.kt b/src/en/mangarock/src/eu/kanade/tachiyomi/extension/en/mangarock/MangaRock.kt index 1bc04c07a..ca0a1e15c 100644 --- a/src/en/mangarock/src/eu/kanade/tachiyomi/extension/en/mangarock/MangaRock.kt +++ b/src/en/mangarock/src/eu/kanade/tachiyomi/extension/en/mangarock/MangaRock.kt @@ -68,7 +68,11 @@ class MangaRock : HttpSource() { filters.forEach { filter -> when (filter) { is StatusFilter -> { - status = filter.toUriPart() + status = when (filter.state) { + Filter.TriState.STATE_INCLUDE -> "completed" + Filter.TriState.STATE_EXCLUDE -> "ongoing" + else -> "all" + } } is RankFilter -> { rank = filter.toUriPart() @@ -177,7 +181,8 @@ class MangaRock : HttpSource() { val obj = JSONObject(response.body()!!.string()).getJSONObject("data") val chapters = ArrayList() 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) chapters.add(SChapter.create().apply { name = chapter.getString("name") @@ -236,11 +241,7 @@ class MangaRock : HttpSource() { return buffer } - private class StatusFilter : UriPartFilter("Completed", arrayOf( - Pair("All", "all"), - Pair("Completed", "completed"), - Pair("Ongoing", "ongoing") - )) + private class StatusFilter : Filter.TriState("Completed") private class RankFilter : UriPartFilter("Rank", arrayOf( Pair("All", "all"),