出入库功能改版
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
package com.sw.inbound.dialog
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.sw.inbound.activity.GoodsListActivity
|
||||
import com.sw.inbound.adapter.RecognizeAdapter
|
||||
import com.sw.inbound.databinding.DialogGoodsRecognizeBinding
|
||||
import com.sw.inbound.databinding.LayoutEmptyRecognizeBinding
|
||||
import com.sw.inbound.model.response.SearchGoodsInfo
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
class GoodsRecognizeDialog(
|
||||
context: Context,
|
||||
var list: MutableList<SearchGoodsInfo.Record>,
|
||||
var dismissDialog: () -> Unit,
|
||||
var findGoods: () -> Unit
|
||||
) : BaseDialog(context) {
|
||||
|
||||
private lateinit var binding: DialogGoodsRecognizeBinding
|
||||
private lateinit var inflater: LayoutInflater
|
||||
override fun getRootView(): View {
|
||||
inflater = LayoutInflater.from(context)
|
||||
binding = DialogGoodsRecognizeBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun dismiss() {
|
||||
dismissDialog()
|
||||
super.dismiss()
|
||||
}
|
||||
|
||||
private val recognizeAdapter by lazy {
|
||||
RecognizeAdapter(list).apply {
|
||||
isStateViewEnable = true
|
||||
setOnItemClickListener { adapter, view, position ->
|
||||
if (list[position].isSelected) {
|
||||
GoodsStoreDialog(context, list[position]) {
|
||||
activity?.addGoods(it)
|
||||
}.show()
|
||||
return@setOnItemClickListener
|
||||
}
|
||||
list.forEach { item ->
|
||||
item.isSelected = false
|
||||
}
|
||||
list[position].isSelected = true
|
||||
notifyDataSetChanged()
|
||||
GoodsStoreDialog(context, list[position]) {
|
||||
activity?.addGoods(it)
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var activity: GoodsListActivity? = null
|
||||
override fun initView() {
|
||||
activity = getReceiptActivity()
|
||||
binding.rvRecognize.let {
|
||||
it.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||
it.adapter = recognizeAdapter
|
||||
}
|
||||
if (recognizeAdapter.list.isEmpty()) {
|
||||
loadEmptyView()
|
||||
}
|
||||
binding.ivClose.setOnClickListener { dismiss() }
|
||||
binding.btnManuallyFind.setOnClickListener {
|
||||
findGoods()
|
||||
//dismiss()
|
||||
}
|
||||
binding.btnAgainRecognize.setOnClickListener {
|
||||
dismiss()
|
||||
activity?.recognizeFood()
|
||||
}
|
||||
}
|
||||
|
||||
private var emptyBinding: LayoutEmptyRecognizeBinding? = null
|
||||
private fun loadEmptyView() {
|
||||
if (emptyBinding == null) {
|
||||
emptyBinding = LayoutEmptyRecognizeBinding.inflate(inflater, binding.rvRecognize, false)
|
||||
}
|
||||
emptyBinding?.root?.let {
|
||||
recognizeAdapter.stateView = it
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user