Toonily: Update search filters (#1483)
Signed-off-by: Rama Bondan Prakoso <ramanarubp@gmail.com>
This commit is contained in:
parent
db1dd7bf1b
commit
b845d9db6e
@ -5,7 +5,7 @@ ext {
|
|||||||
appName = 'Tachiyomi: Toonily'
|
appName = 'Tachiyomi: Toonily'
|
||||||
pkgNameSuffix = 'en.toonily'
|
pkgNameSuffix = 'en.toonily'
|
||||||
extClass = '.Toonily'
|
extClass = '.Toonily'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,20 +51,22 @@ class Toonily: ParsedHttpSource() {
|
|||||||
url.addQueryParameter("post_type","wp-manga")
|
url.addQueryParameter("post_type","wp-manga")
|
||||||
val pattern = "\\s+".toRegex()
|
val pattern = "\\s+".toRegex()
|
||||||
val q = query.replace(pattern, "+")
|
val q = query.replace(pattern, "+")
|
||||||
if(query.length > 0){
|
if(query.isNotEmpty()){
|
||||||
url.addQueryParameter("s", q)
|
url.addQueryParameter("s", q)
|
||||||
}else{
|
}else{
|
||||||
url.addQueryParameter("s", "")
|
url.addQueryParameter("s", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
var orderBy = ""
|
var orderBy = ""
|
||||||
|
var condFilter = ""
|
||||||
|
var adultFilter = ""
|
||||||
|
|
||||||
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
|
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
|
||||||
when (filter) {
|
when (filter) {
|
||||||
is GenreList -> {
|
is GenreList -> {
|
||||||
val genreInclude = mutableListOf<String>()
|
val genreInclude = mutableListOf<String>()
|
||||||
filter.state.forEach {
|
filter.state.forEach {
|
||||||
if (it.state == 1) {
|
if (it.state) {
|
||||||
genreInclude.add(it.id)
|
genreInclude.add(it.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +79,7 @@ class Toonily: ParsedHttpSource() {
|
|||||||
is StatusList ->{
|
is StatusList ->{
|
||||||
val statuses = mutableListOf<String>()
|
val statuses = mutableListOf<String>()
|
||||||
filter.state.forEach {
|
filter.state.forEach {
|
||||||
if (it.state == 1) {
|
if (it.state) {
|
||||||
statuses.add(it.id)
|
statuses.add(it.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,9 +91,17 @@ class Toonily: ParsedHttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is SortBy -> {
|
is SortBy -> {
|
||||||
orderBy = filter.toUriPart();
|
orderBy = filter.toUriPart()
|
||||||
url.addQueryParameter("m_orderby",orderBy)
|
url.addQueryParameter("m_orderby",orderBy)
|
||||||
}
|
}
|
||||||
|
is CondFilter -> {
|
||||||
|
condFilter = filter.toUriPart()
|
||||||
|
url.addQueryParameter("op",condFilter)
|
||||||
|
}
|
||||||
|
is AdultFilter -> {
|
||||||
|
adultFilter = filter.toUriPart()
|
||||||
|
url.addQueryParameter("adult",adultFilter)
|
||||||
|
}
|
||||||
is TextField -> url.addQueryParameter(filter.key, filter.state)
|
is TextField -> url.addQueryParameter(filter.key, filter.state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,37 +188,57 @@ class Toonily: ParsedHttpSource() {
|
|||||||
Pair("Most View", "views"),
|
Pair("Most View", "views"),
|
||||||
Pair("New", "new-manga")
|
Pair("New", "new-manga")
|
||||||
))
|
))
|
||||||
private class Genre(name: String, val id: String = name) : Filter.TriState(name)
|
private class CondFilter : UriPartFilter("Genres condition", arrayOf(
|
||||||
|
Pair("OR (having one of selected genres)", ""),
|
||||||
|
Pair("AND (having all selected genres)", "1")
|
||||||
|
))
|
||||||
|
private class AdultFilter : UriPartFilter("Adult content", arrayOf(
|
||||||
|
Pair("All", ""),
|
||||||
|
Pair("None adult content", "0"),
|
||||||
|
Pair("Only adult content", "1")
|
||||||
|
))
|
||||||
|
private class Genre(name: String, val id: String = name) : Filter.CheckBox(name)
|
||||||
private class GenreList(genres: List<Genre>) : Filter.Group<Genre>("Genres", genres)
|
private class GenreList(genres: List<Genre>) : Filter.Group<Genre>("Genres", genres)
|
||||||
private class Status(name: String, val id: String = name) : Filter.TriState(name)
|
private class Status(name: String, val id: String = name) : Filter.CheckBox(name)
|
||||||
private class StatusList(statuses: List<Status>) : Filter.Group<Status>("Status", statuses)
|
private class StatusList(statuses: List<Status>) : Filter.Group<Status>("Status", statuses)
|
||||||
|
|
||||||
override fun getFilterList() = FilterList(
|
override fun getFilterList() = FilterList(
|
||||||
// TextField("Judul", "title"),
|
//TextField("Judul", "title"),
|
||||||
TextField("Author", "author"),
|
TextField("Author", "author"),
|
||||||
TextField("Artist", "artist"),
|
TextField("Artist", "artist"),
|
||||||
TextField("Year", "release"),
|
TextField("Year", "release"),
|
||||||
SortBy(),
|
SortBy(),
|
||||||
|
CondFilter(),
|
||||||
|
AdultFilter(),
|
||||||
StatusList(getStatusList()),
|
StatusList(getStatusList()),
|
||||||
GenreList(getGenreList())
|
GenreList(getGenreList())
|
||||||
)
|
)
|
||||||
private fun getStatusList() = listOf(
|
private fun getStatusList() = listOf(
|
||||||
Status("Completed","complete"),
|
Status("Completed","end"),
|
||||||
Status("Ongoing","on-going"),
|
Status("Ongoing","on-going"),
|
||||||
Status("Canceled","canceled"),
|
Status("Canceled","canceled"),
|
||||||
Status("Onhold","on-hold")
|
Status("Onhold","on-hold")
|
||||||
)
|
)
|
||||||
private fun getGenreList() = listOf(
|
private fun getGenreList() = listOf(
|
||||||
Genre("Action","action-webtoon"),
|
Genre("Action", "action-webtoon"),
|
||||||
Genre("Adventure","adventure-webtoon"),
|
Genre("Adventure", "adventure-webtoon"),
|
||||||
Genre("Comedy","comedy-webtoon"),
|
Genre("Comedy", "comedy-webtoon"),
|
||||||
Genre("Drama","drama-webtoon"),
|
Genre("Drama", "drama-webtoon"),
|
||||||
Genre("Fantasy","fantasy-webtoon"),
|
Genre("Fantasy", "fantasy-webtoon"),
|
||||||
Genre("Harem","harem-webtoon"),
|
Genre("Harem", "harem-webtoon"),
|
||||||
Genre("Romance","romance-webtoon"),
|
Genre("Horror", "horror-webtoon"),
|
||||||
Genre("School LIfe","school-life-webtoon"),
|
Genre("Mature", "mature-webtoon"),
|
||||||
Genre("Sci Fi","scifi-webtoon"),
|
Genre("Mystery", "mystery-webtoon"),
|
||||||
Genre("Supernatural","supernatural-webtoon")
|
Genre("Psychological", "psychological-webtoon"),
|
||||||
|
Genre("Romance", "romance-webtoon"),
|
||||||
|
Genre("School life", "school-life-webtoon"),
|
||||||
|
Genre("Sci-Fi", "scifi-webtoon"),
|
||||||
|
Genre("Seinen", "seinen-webtoon"),
|
||||||
|
Genre("Shounen", "shounen-webtoon"),
|
||||||
|
Genre("Supernatural", "supernatural-webtoon"),
|
||||||
|
Genre("Thriller", "thriller-webtoon"),
|
||||||
|
Genre("Yaoi", "yaoi-webtoon"),
|
||||||
|
Genre("Yuri", "yuri-webtoon")
|
||||||
)
|
)
|
||||||
private open class UriPartFilter(displayName: String, val vals: Array<Pair<String, String>>) :
|
private open class UriPartFilter(displayName: String, val vals: Array<Pair<String, String>>) :
|
||||||
Filter.Select<String>(displayName, vals.map { it.first }.toTypedArray()) {
|
Filter.Select<String>(displayName, vals.map { it.first }.toTypedArray()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user