Commit 6af676fb authored by yinjiacheng's avatar yinjiacheng

fix 商品上下架后处理商品列表恰好为空情况

parent 95c0a5d6
......@@ -11,6 +11,7 @@ import androidx.databinding.BindingAdapter
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CenterCrop
......@@ -79,6 +80,11 @@ class CommodityListAdapter(private val context: Context, private val status: Com
*/
private val commodityData by lazy { ArrayList<Goods>() }
/**
* 商品数据变化
*/
val commodityDataChange by lazy { MutableLiveData<ArrayList<Goods>>() }
/**
* 更新数据
*/
......@@ -167,6 +173,7 @@ class CommodityListAdapter(private val context: Context, private val status: Com
ToastUtil.showToast(context, "下架成功")
commodityData.remove(data)
notifyItemRemoved(position)
commodityDataChange.value = commodityData
})
}
is CommodityAuditItemViewHolder -> {
......@@ -183,6 +190,7 @@ class CommodityListAdapter(private val context: Context, private val status: Com
ToastUtil.showToast(context, "上架成功")
commodityData.remove(data)
notifyItemRemoved(position)
commodityDataChange.value = commodityData
})
}
}
......
......@@ -49,6 +49,7 @@ class CommodityListFragment(private val status: CommodityStatus) :
* 订阅数据
*/
private fun subscribeLiveData() {
// 下拉刷新完成
vm.refreshFinish.observe(this, {
binding.rlCommodityList.finishRefresh()
if (it.isNullOrEmpty()) {
......@@ -58,10 +59,17 @@ class CommodityListFragment(private val status: CommodityStatus) :
adapter?.updateData(it)
}
})
// 上拉加载更多完成
vm.loadMoreFinish.observe(this, {
binding.rlCommodityList.finishLoadMore()
adapter?.insertData(it)
})
// 商品数据变化
adapter?.commodityDataChange?.observe(this, {
if (it.isNullOrEmpty()) {
binding.pvEmptyPage.isVisible = true
}
})
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment