private fun postDeleteCart(ids: MutableList<String>) {
val map = mutableMapOf<String, MutableList<String>>()
map["cartIds"] = ids
productService.delCart(map)
.doOnSubscribe(dialog)
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : CustomDisposable<Response<ResponseBody>>(mContext, dialog) {
override fun onNext(t: Response<ResponseBody>) {
super.onNext(t)
if (t != null) {
//删除数据自动消失,不用刷新
val iter = mCartAdapter?.list?.iterator()
while (iter!!.hasNext()) {
val item = iter.next()
if (item.isCheckedBo) { //isCheckedBo 选中的商品id
iter.remove()
cart_rv.post {
mCartAdapter?.notifyDataSetChanged()
}
}
}
}
kotlin 购物车 删除数据自动消失,不用刷新 不显示闪
最新推荐文章于 2023-04-21 09:15:29 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)