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()
}
}
}
}
|