I have a Recyclerview in my activity. when I pull down it will load new items to recycle view. Now I need to implement pull to refresh the concept to my recyclerview. I have
For perfect control position system, add each item's position in arraylist. For new item position will be 0. Use Comparator and sort items by using Collection Class.
Collections.sort(arrayOfPosts, new SortPostByPosition());
listAdapter.notifyDataSetChanged();
Here is SortPostByPosition class that compare position of each item.
class SortPostByPosition implements Comparator {
public int compare(TimelineListData a, TimelineListData b) {
return Integer.compare(a.position, b.position);
// you can compare by your own complex formula too
}
}