Posts

Showing posts with the label sortedlist

RecycylerView with SortedList shows duplicate items

RecycylerView with SortedList shows duplicate items I use an SortedList with a RecyclerViewAdapter for my list. Therefore I send my items (loaded from my backend in a background thread) via an listener to my GameListAdapter . According to the implemented logic in my SortedListAdapterCallback items sent to the adapter with the same id should be replaced instead of being inserted multiple times. Unfortunately this is mainly, but not always the case. SortedList RecyclerViewAdapter GameListAdapter SortedListAdapterCallback This is the constructor of my GameListAdapter GameListAdapter public GameListAdapter(RecyclerView list) { this.list = list; gamelistItems = new SortedList<>(GameListItem.class, new SortedListAdapterCallback<GameListItem>(this) { @Override public int compare(GameListItem o1, GameListItem o2) { return o1.getDate().compareTo(o2.getDate()); } @Override public boolean areContentsTheSame(GameListItem ol...