Skip to content

Instantly share code, notes, and snippets.

View UbadahJ's full-sized avatar
😁
Silicon Sorcerer

LordChadiwala UbadahJ

😁
Silicon Sorcerer
View GitHub Profile
import android.view.View
import androidx.core.view.ViewCompat
import androidx.core.view.get
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
interface StickyViewHolder<T> {
val type: Int
val root: View
fun bind(item: T)
@UbadahJ
UbadahJ / FilterableListAdapter.kt
Last active May 5, 2024 02:25
A filterable ListAdapter for RecyclerView
abstract class FilterableListAdapter<T, VH : RecyclerView.ViewHolder>(
diffCallback: DiffUtil.ItemCallback<T>
) : ListAdapter<T, VH>(diffCallback), Filterable {
private var originalList: List<T> = currentList.toList()
override fun getFilter(): Filter {
return object : Filter() {
override fun performFiltering(constraint: CharSequence?): FilterResults {
return FilterResults().apply {