@OnClick(R2.id.tv_top_shop_cart_del)
void onClickRemoveSelectedItem(){
final List<MultipleItemEntity> data = mAdapter.getData();
// 要删除的数据
final List<MultipleItemEntity> deleteEntities = new ArrayList<>();
int i = 0;
for (MultipleItemEntity entity : data){
final boolean isSelected = entity.getField(ShopCartMultipleFields.IS_SELECTED);
entity.setField(ShopCartMultipleFields.POSITION, i);
if (isSelected){
deleteEntities.add(entity);
}
i++;
}
for (MultipleItemEntity entity : deleteEntities){
final int removePosition = entity.getField(ShopCartMultipleFields.POSITION);
if (removePosition <= mAdapter.getItemCount()) {
mAdapter.remove(removePosition);
//更新数据
mAdapter.notifyItemRangeChanged(removePosition, mAdapter.getItemCount());
}
}
checkItemCount();
}