Reputation: 301
I have a vertical RecyclerView
with each item having horizontal RecyclerView
.
When i am updating the RecyclerView
UI Freeze for some seconds.
update code :
public void setData(List<SectionList> data) {
if (this.sectionListDetails != data) {
this.sectionListDetails = data;
notifyDataSetChanged();
}
}
Upvotes: 0
Views: 2323
Reputation: 87
You can use notifyItemRangeChanged(startIndex, endIndex)
to make the rendering faster. I am attaching my adapter add() method for your better understanding.
fun add(orders: List<OnlineOrderResponseModel.Data>, orderTab: String) {
this.orderList.addAll(orders as ArrayList<OnlineOrderResponseModel.Data>)
this.filterList.addAll(orders)
notifyItemRangeChanged(((orderList.size-1) - (orders.size-1)), orderList.size)
}
Upvotes: 0
Reputation: 801
Using RecyclerView
in RecyclerView
is what is making it processing intensive and causing delayed rendering of views on screen. Also the computing comnplexity of your both adapter code matters how Android framework will execute it. But i think instead of calling notifyDataSetChanged()
(which re-renders displayed items and also the nested horizontal adapter in every row which is apparently processing intensive) try using following methods which can help reduce unnecessary processing
notifyItemChanged(int)
notifyItemInserted(int)
notifyItemRemoved(int)
notifyItemRangeChanged(int, int)
notifyItemRangeInserted(int, int)
notifyItemRangeRemoved(int, int)
using which you can taget to specific item(s). Check this link for more
Upvotes: 2