Skip to content

Commit

Permalink
Remove area search when didn't fill input box (yujincheng08#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
david082321 authored Sep 27, 2021
1 parent 553d2c6 commit 7465623
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions app/src/main/java/me/iacn/biliroaming/hook/BangumiSeasonHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,24 @@ class BangumiSeasonHook(classLoader: ClassLoader) : BaseHook(classLoader) {
mClassLoader
)
val pageArrays = pageTypesClass.getStaticObjectFieldAs<Array<Any>>("\$VALUES")
val newPageArray = pageArrays.copyOf(pageArrays.size + 4)
var counter = 0
for (area in AREA_TYPES) {
newPageArray[pageArrays.size + counter++] = pageTypesClass.new(
"PAGE_BANGUMI",
4,
"bilibili://search-result/new-bangumi?from=" + area.value.type,
area.key,
"bangumi"
)
if (!sPrefs.getString(area.value.type + "_server", null).isNullOrBlank()) {
counter++
}
}
val newPageArray = pageArrays.copyOf(pageArrays.size + counter)
counter = 0
for (area in AREA_TYPES) {
if (!sPrefs.getString(area.value.type + "_server", null).isNullOrBlank()) {
newPageArray[pageArrays.size + counter++] = pageTypesClass.new(
"PAGE_BANGUMI",
4,
"bilibili://search-result/new-bangumi?from=" + area.value.type,
area.key,
"bangumi"
)
}
}
pageTypesClass.setStaticObjectField("\$VALUES", newPageArray)
}
Expand Down Expand Up @@ -340,13 +348,15 @@ class BangumiSeasonHook(classLoader: ClassLoader) : BaseHook(classLoader) {
body ?: return
if (sPrefs.getBoolean("hidden", false) && sPrefs.getBoolean("search_area", false)) {
for (area in AREA_TYPES) {
searchAllResultNavInfoClass?.new()?.run {
setObjectField("name", area.value.text)
setIntField("pages", 0)
setIntField("total", 0)
setIntField("type", area.key)
}?.also {
body.getObjectFieldAs<MutableList<Any>>("nav").add(1, it)
if (!sPrefs.getString(area.value.type + "_server", null).isNullOrBlank()) {
searchAllResultNavInfoClass?.new()?.run {
setObjectField("name", area.value.text)
setIntField("pages", 0)
setIntField("total", 0)
setIntField("type", area.key)
}?.also {
body.getObjectFieldAs<MutableList<Any>>("nav").add(1, it)
}
}
}
}
Expand Down

0 comments on commit 7465623

Please sign in to comment.