This commit is contained in:
FooIbar authored and tarsin committed 2023-02-15 02:17:23 +08:00
1 parent 63cd60b237
commit 621772f359
2 files changed
+21 -9

No files matched your search

@@ -164,7 +164,6 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
}
}
private var mHasFirstRefresh = false
private var mNavCheckedId = 0
private val mDownloadManager: DownloadManager = downloadManager
@SuppressLint("NotifyDataSetChanged")
@@ -211,8 +210,9 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
ACTION_SUBSCRIPTION -> ListUrlBuilder(MODE_SUBSCRIPTION)
ACTION_WHATS_HOT -> ListUrlBuilder(MODE_WHATS_HOT)
ACTION_TOP_LIST -> ListUrlBuilder(MODE_TOPLIST, mKeyword = "11")
ACTION_LIST_URL_BUILDER -> args?.getParcelable<ListUrlBuilder>(KEY_LIST_URL_BUILDER)
?.copy() ?: ListUrlBuilder()
ACTION_LIST_URL_BUILDER ->
args?.getParcelableCompat<ListUrlBuilder>(KEY_LIST_URL_BUILDER)?.copy()
?: ListUrlBuilder()
else -> throw IllegalStateException("Wrong KEY_ACTION:${args?.getString(KEY_ACTION)} when handle args!")
}
@@ -324,8 +324,11 @@ class GalleryListScene : SearchBarScene(), OnDragHandlerListener, SearchLayout.H
binding.fabLayout.setSecondaryFabVisibilityAt(0, !isPopular)
binding.fabLayout.setSecondaryFabVisibilityAt(2, !isPopular)
// Update normal search mode
// Update normal search mode and category
binding.searchLayout.setNormalSearchMode(if (mode == MODE_SUBSCRIPTION) R.id.search_subscription_search else R.id.search_normal_search)
if (category != EhUtils.NONE) {
binding.searchLayout.setCategory(category)
}
// Update search edit text
if (!mIsTopList) {
@@ -29,6 +29,7 @@ import android.view.ViewGroup
import android.widget.*
import androidx.annotation.IntDef
import androidx.core.content.edit
import androidx.core.view.forEach
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager
@@ -103,8 +104,8 @@ class SearchLayout @JvmOverloads constructor(
mChip.isChecked = NumberUtils.int2boolean(mPair.first and mCategoryStored)
mChip.setOnLongClickListener {
if (mChip.isChecked) {
for (i in 0 until mCategoryGroup.childCount) {
(mCategoryGroup.getChildAt(i) as Chip).isChecked = true
mCategoryGroup.forEach {
(it as IdentifiedChip).isChecked = true
}
mChip.isChecked = false
} else {
@@ -115,10 +116,10 @@ class SearchLayout @JvmOverloads constructor(
}
mCategoryGroup.addView(mChip)
}
mCategoryGroup.setOnCheckedStateChangeListener { _, checkedIds ->
mCategoryGroup.setOnCheckedStateChangeListener { group, checkedIds ->
var mCategory = 0
for (index in checkedIds) {
mCategory = mCategory or findViewById<IdentifiedChip>(index).idt
mCategory = mCategory or group.findViewById<IdentifiedChip>(index).idt
}
mSharePref.edit { putInt(SEARCH_CATEGORY_PREF, mCategory) }
}
@@ -160,6 +161,14 @@ class SearchLayout @JvmOverloads constructor(
mNormalSearchMode.check(id)
}
fun setCategory(category: Int) {
mCategoryGroup.forEach {
(it as IdentifiedChip).apply {
isChecked = idt and category != 0
}
}
}
override fun onSelectImage() {
if (mHelper != null) {
mHelper!!.onSelectImage()
@@ -245,7 +254,7 @@ class SearchLayout @JvmOverloads constructor(
post { setSearchMode(tab.position) }
}
fun setSearchMode(@SearchMode mode: Int) {
private fun setSearchMode(@SearchMode mode: Int) {
val oldItemCount = mAdapter.itemCount
mSearchMode = mode
val newItemCount = mAdapter.itemCount