offline novel

This commit is contained in:
Finnley Somdahl 2023-12-03 22:18:06 -06:00
parent 111fb16266
commit 3ded6ba87a
18 changed files with 512 additions and 212 deletions

View file

@ -13,10 +13,12 @@ import ani.dantotsu.R
class OfflineMangaAdapter(
private val context: Context,
private val items: List<OfflineMangaModel>
private var items: List<OfflineMangaModel>,
private val searchListener: OfflineMangaSearchListener
) : BaseAdapter() {
private val inflater: LayoutInflater =
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
private var originalItems: List<OfflineMangaModel> = items
override fun getCount(): Int {
return items.size
@ -54,4 +56,22 @@ class OfflineMangaAdapter(
}
return view
}
fun onSearchQuery(query: String) {
// Implement the filtering logic here, for example:
items = if (query.isEmpty()) {
// Return the original list if the query is empty
originalItems
} else {
// Filter the list based on the query
originalItems.filter { it.title.contains(query, ignoreCase = true) }
}
notifyDataSetChanged() // Notify the adapter that the data set has changed
}
fun setItems(items: List<OfflineMangaModel>) {
this.items = items
this.originalItems = items
notifyDataSetChanged()
}
}