i have recyclerView in my fragment and i want to change the list of data in the recyclerView adapter without refreshing the recyclerView i am using this two functions like that
mAdapter.clearList() mAdapter.addItems(newList)
but there is a quick refresh because of clearList() function anyone have better function to use
fun addItems(items: List<T>) {
val myList = adapterItems()
var count = myList.size
// Remove loading indicator dummy item
if (count > 0 && hasMore()) {
count--
myList.removeAt(count)
notifyItemRemoved(count)
}
// Insert extra data
myList.addAll(items)
notifyItemRangeInserted(count, items.size)
}
fun clearList() {
val myList = adapterItems()
val count = myList.size
myList.clear()
notifyItemRangeRemoved(0, count)
}