-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于数据更新的问题 #8
Comments
你点+号的时候就是添加图片,不管他是否重复,点击原来图片的时候,只让他选择一张图片,或者仿照朋友圈,外面不要删除,里面放删除,就是不让他可以添加多张图片 |
刚试了一下下面这个方法,可以暂时实现我的需求 public <T extends ImageShowPickerBean> void addData(List<T> list) {
if (list == null) {
return;
}
for (int i = 0; i < list.size(); i++) {
T t = list.get(i);
for (ImageShowPickerBean bean : this.list) {
if (TextUtils.equals(t.getImageShowPickerUrl(), bean.getImageShowPickerUrl())) {
list.remove(i);
i--;
}
}
}
this.list.addAll(list);
if (isShowAnim) {
if (adapter != null)
adapter.notifyItemRangeChanged(this.list.size() - list.size(), list.size());
} else {
if (adapter != null)
adapter.notifyDataSetChanged();
}
} |
这样不太好吧,你这样处理的话,只要点击之前的已选中图片,就会触发全部重置,感觉逻辑不通 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
选择图片会出现重复的现象,这样就需要将之前选择的数据进行清空后重新加载,但是好像没有找到清空的方法,如果直接在修改addData()方法加入 this.list.clear();会导致加号图片消失。
作者有什么好的方法来实现这个功能吗?
功能举例:第一次选择了三张图片,第二次重新选择包括之前三张图片在内的四张,返回后显示的图片总数是七张,实际应该显示四张。
The text was updated successfully, but these errors were encountered: