mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
refactor (search filter) : syncing main tytype chips and bottom dialog tytype chips (#811)
This commit is contained in:
parent
fe30a85a1c
commit
91dc83e6a3
1 changed files with 16 additions and 6 deletions
|
@ -256,12 +256,12 @@ class SearchFragment : Fragment() {
|
|||
|
||||
builder.behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
|
||||
val binding: HomeSelectMainpageBinding = HomeSelectMainpageBinding.inflate(
|
||||
val selectMainpageBinding: HomeSelectMainpageBinding = HomeSelectMainpageBinding.inflate(
|
||||
builder.layoutInflater,
|
||||
null,
|
||||
false
|
||||
)
|
||||
builder.setContentView(binding.root)
|
||||
builder.setContentView(selectMainpageBinding.root)
|
||||
builder.show()
|
||||
builder.let { dialog ->
|
||||
val isMultiLang = ctx.getApiProviderLangSettings().let { set ->
|
||||
|
@ -315,16 +315,23 @@ class SearchFragment : Fragment() {
|
|||
arrayAdapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
val selectedSearchTypes = DataStoreHelper.searchPreferenceTags
|
||||
|
||||
bindChips(
|
||||
binding.tvtypesChipsScroll.tvtypesChips,
|
||||
selectMainpageBinding.tvtypesChipsScroll.tvtypesChips,
|
||||
selectedSearchTypes,
|
||||
TvType.values().toList()
|
||||
validAPIs.flatMap { api -> api.supportedTypes }.distinct()
|
||||
) { list ->
|
||||
updateList(list)
|
||||
|
||||
// refresh selected chips in main chips
|
||||
if (selectedSearchTypes.toSet() != list.toSet()) {
|
||||
selectedSearchTypes.clear()
|
||||
selectedSearchTypes.addAll(list)
|
||||
updateChips(binding?.tvtypesChipsScroll?.tvtypesChips, selectedSearchTypes)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cancelBtt?.setOnClickListener {
|
||||
dialog.dismissSafe()
|
||||
}
|
||||
|
@ -343,6 +350,9 @@ class SearchFragment : Fragment() {
|
|||
dialog.setOnDismissListener {
|
||||
DataStoreHelper.searchPreferenceProviders = currentSelectedApis.toList()
|
||||
selectedApis = currentSelectedApis
|
||||
|
||||
// run search when dialog is close
|
||||
search(binding?.mainSearch?.query?.toString())
|
||||
}
|
||||
updateList(selectedSearchTypes.toList())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue