fradiati
12/09/2019, 8:23 AMdiesieben07
12/09/2019, 8:24 AMmyMutableList
created? And can you show the stacktrace?fradiati
12/09/2019, 8:26 AMabstract class BaseRecyclerAdapter<T>(
private var masterList: MutableList<T> = mutableListOf()
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
fun updateList(list: List<T>) {
masterList.clear()
masterList.addAll(list as MutableList<T>)
notifyDataSetChanged()
}
diesieben07
12/09/2019, 8:27 AMMutableList<T>
? addAll
accepts a plain List<T>
, no need for a mutable list.fradiati
12/09/2019, 8:27 AMdiesieben07
12/09/2019, 8:28 AMmutableListOf
returns an ArrayList
, which overrides add
fradiati
12/09/2019, 8:28 AMfun updateList(list: List<T>) {
masterList.clear()
masterList.addAll(list)
notifyDataSetChanged()
}
adapterBlog.updateList((List<BlogPost>) results);
diesieben07
12/09/2019, 8:29 AMmasterList
still an ArrayList
?fradiati
12/09/2019, 8:32 AMdiesieben07
12/09/2019, 8:33 AMmasterList
anywhere else? Like masterList = ...
anywhere?fradiati
12/09/2019, 8:34 AMdiesieben07
12/09/2019, 8:34 AMCollections.EmptyList
...