nhentai language filtering, added dev build in settings
This commit is contained in:
parent
9ed7ee65c3
commit
d61adc0259
@ -56,13 +56,20 @@ class NHentai(context: Context) : HttpSource(), LewdSource<NHentaiSearchMetadata
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun searchMangaRequestObservable(page: Int, query: String, filters: FilterList): Observable<Request> {
|
private fun searchMangaRequestObservable(page: Int, query: String, filters: FilterList): Observable<Request> {
|
||||||
|
val langFilter = filters.filterIsInstance<filterLang>().firstOrNull()
|
||||||
|
var langFilterString = ""
|
||||||
|
if (langFilter != null) {
|
||||||
|
langFilterString = SOURCE_LANG_LIST.first {it.first == langFilter!!.values[langFilter!!.state]}.second
|
||||||
|
}
|
||||||
|
|
||||||
val uri = if(query.isNotBlank()) {
|
val uri = if(query.isNotBlank()) {
|
||||||
Uri.parse("$baseUrl/search/").buildUpon().apply {
|
Uri.parse("$baseUrl/search/").buildUpon().apply {
|
||||||
appendQueryParameter("q", query)
|
appendQueryParameter("q", query+langFilterString)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Uri.parse(baseUrl).buildUpon()
|
Uri.parse(baseUrl).buildUpon()
|
||||||
}
|
}
|
||||||
|
|
||||||
val sortFilter = filters.filterIsInstance<SortFilter>().firstOrNull()?.state
|
val sortFilter = filters.filterIsInstance<SortFilter>().firstOrNull()?.state
|
||||||
?: defaultSortFilterSelection()
|
?: defaultSortFilterSelection()
|
||||||
|
|
||||||
@ -243,7 +250,10 @@ class NHentai(context: Context) : HttpSource(), LewdSource<NHentaiSearchMetadata
|
|||||||
throw NotImplementedError("Unused method called!")
|
throw NotImplementedError("Unused method called!")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFilterList() = FilterList(SortFilter())
|
override fun getFilterList() = FilterList(SortFilter(), filterLang())
|
||||||
|
|
||||||
|
//language filtering
|
||||||
|
private class filterLang : Filter.Select<String>("Language", SOURCE_LANG_LIST.map { it.first }.toTypedArray())
|
||||||
|
|
||||||
class SortFilter : Filter.Sort(
|
class SortFilter : Filter.Sort(
|
||||||
"Sort",
|
"Sort",
|
||||||
@ -293,6 +303,14 @@ class NHentai(context: Context) : HttpSource(), LewdSource<NHentaiSearchMetadata
|
|||||||
|
|
||||||
private fun defaultSortFilterSelection() = Filter.Sort.Selection(0, false)
|
private fun defaultSortFilterSelection() = Filter.Sort.Selection(0, false)
|
||||||
|
|
||||||
|
private val SOURCE_LANG_LIST = listOf(
|
||||||
|
Pair("All", ""),
|
||||||
|
Pair("English", " english"),
|
||||||
|
Pair("Japanese", " japanese"),
|
||||||
|
Pair("Chinese", " chinese")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
val jsonParser by lazy {
|
val jsonParser by lazy {
|
||||||
JsonParser()
|
JsonParser()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user