餐盘柜接口改造
This commit is contained in:
@@ -12,6 +12,7 @@ import com.sw.platecabinet.activity.UnBindDialogActivity
|
||||
import com.sw.platecabinet.databinding.FragmentUnbindPlateBinding
|
||||
import com.sw.platecabinet.ext.maskName
|
||||
import com.sw.platecabinet.ext.maskPhone
|
||||
import com.sw.platecabinet.model.ErrorInfo
|
||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -38,16 +39,15 @@ class UnBindPlateFragment private constructor() : BaseFragment<FragmentUnbindPla
|
||||
ActivityResultContracts.StartActivityForResult()
|
||||
) { result ->
|
||||
if (result.resultCode == Activity.RESULT_OK) {
|
||||
viewModel.unbindPlate(
|
||||
equipmentBoxCode = info!!.equipmentBoxCode!!,
|
||||
equipmentCode = info!!.equipmentCode!!
|
||||
)
|
||||
viewModel.unbindPlate(info!!.id!!) { pair ->
|
||||
updateBindState(pair)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun initialize() {
|
||||
arguments?.let {
|
||||
info = it.getParcelable(ARG_PARAM1)
|
||||
arguments?.let { args ->
|
||||
info = args.getParcelable(ARG_PARAM1)
|
||||
info?.let {
|
||||
binding.tvNum.text = "${it.equipmentName}-${it.equipmentBoxCode}"
|
||||
binding.tvPlateNumberValue.text = it.plateNumber
|
||||
@@ -73,20 +73,23 @@ class UnBindPlateFragment private constructor() : BaseFragment<FragmentUnbindPla
|
||||
|
||||
override fun registerDataChange() {
|
||||
super.registerDataChange()
|
||||
lifecycleScope.launch {
|
||||
viewModel.bindStateChange.collect {
|
||||
if (it.first == null) return@collect // 绑定状态过滤
|
||||
val errorInfo = it.second
|
||||
if (errorInfo.isSuccess()) {
|
||||
ToastUtils.showToast("解绑成功")
|
||||
// lifecycleScope.launch {
|
||||
// viewModel.bindStateChange.collect {
|
||||
// updateBindState(it)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
private fun updateBindState(pair: Pair<Boolean?, ErrorInfo>){
|
||||
if (pair.first == null) return // 绑定状态过滤
|
||||
val errorInfo = pair.second
|
||||
if (errorInfo.isSuccess()) {
|
||||
ToastUtils.showToast("解绑成功")
|
||||
// activity?.finish()
|
||||
// 关闭宿主 Activity
|
||||
requireActivity().finish()
|
||||
requireActivity().overridePendingTransition(0, 0)
|
||||
} else {
|
||||
ToastUtils.showToast(errorInfo.msg)
|
||||
}
|
||||
}
|
||||
// 关闭宿主 Activity
|
||||
requireActivity().finish()
|
||||
requireActivity().overridePendingTransition(0, 0)
|
||||
} else {
|
||||
ToastUtils.showToast(errorInfo.msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user