abstract class BaseRecyclerSearchable(private val mOriginal: MutableList) : RecyclerView.Adapter() { private var mAdapterList: MutableList? = null init { mAdapterList = mOriginal } private var searchQuery: String? = null fun filter(text: String) { searchQuery = text var text = text mAdapterList?.clear() if (text.isEmpty()) { mAdapterList?.addAll(mOriginal)// error here } else { text = text.toLowerCase() mOriginal.forEach { if (it.searchable.toLowerCase().contains(text)) { mAdapterList?.add(it) //error here } } } notifyDataSetChanged() } abstract class BaseHolder(v: View) : RecyclerView.ViewHolder(v) }