ListAdapter not refreshing RecyclerView if I submit the same list with different item order

后端 未结 5 1832
挽巷
挽巷 2021-01-12 06:57

I am using a RecyclerView with ListAdapter (which uses AsyncListDiffer to calculate and animate changes when list is replaced).

The problem is that if I

5条回答
  •  半阙折子戏
    2021-01-12 07:44

    That function will not get called because ListAdapter won't consider it as another list, since it has all the same items only the order got changed.

    @Override
    public void submitList(@Nullable final List list) {
    super.submitList(list != null ? new ArrayList<>(list) : null);
    }
    

    So to solve this, you need to call this function with null first, then immediately call with the order changed list.

    submitList(null);
    submitList(orderChangedList);
    

提交回复
热议问题