JoanZapata/base-adapter-helper

notifyDataSetChanged can not work

chefish opened this issue · 1 comments

public BaseQuickAdapter(Context context, int layoutResId, List<T> data) {
    this.data = data == null ? new ArrayList<T>() : new ArrayList<T>(data);
    this.context = context;
    this.layoutResId = layoutResId;
}

The data is always new. So we cannot use notifyDataSetChanged. I think it shoud be
this.data = data == null ? new ArrayList() : data;

The BaseQuickAdapter creates its own list because it's safer: if you remove an element of your list and don't notify the adapter, it would make your app crash because the adapter will try to build items which don't exist anymore.

If you updated your list, please use replaceAll instead. It will update the internal adapter list and call notifyDatasetChanged() for you.