more searching
This commit is contained in:
parent
3ded6ba87a
commit
c728eae2ba
8 changed files with 190 additions and 35 deletions
|
@ -37,8 +37,9 @@ import kotlinx.coroutines.launch
|
|||
import rx.android.schedulers.AndroidSchedulers
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.Locale
|
||||
|
||||
class InstalledAnimeExtensionsFragment : Fragment() {
|
||||
class InstalledAnimeExtensionsFragment : Fragment(), SearchQueryHandler {
|
||||
|
||||
|
||||
private var _binding: FragmentAnimeExtensionsBinding? = null
|
||||
|
@ -207,6 +208,9 @@ class InstalledAnimeExtensionsFragment : Fragment() {
|
|||
super.onDestroyView();_binding = null
|
||||
}
|
||||
|
||||
override fun updateContentBasedOnQuery(query: String?) {
|
||||
extensionsAdapter.filter(query ?: "", animeExtensionManager.installedExtensionsFlow.value)
|
||||
}
|
||||
|
||||
private class AnimeExtensionsAdapter(
|
||||
private val onSettingsClicked: (AnimeExtension.Installed) -> Unit,
|
||||
|
@ -248,6 +252,16 @@ class InstalledAnimeExtensionsFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
fun filter(query: String, currentList: List<AnimeExtension.Installed>) {
|
||||
val filteredList = ArrayList<AnimeExtension.Installed>()
|
||||
for (extension in currentList) {
|
||||
if (extension.name.lowercase(Locale.ROOT).contains(query.lowercase(Locale.ROOT))) {
|
||||
filteredList.add(extension)
|
||||
}
|
||||
}
|
||||
submitList(filteredList)
|
||||
}
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val extensionNameTextView: TextView = view.findViewById(R.id.extensionNameTextView)
|
||||
val extensionVersionTextView: TextView =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue