修改了配色,添加了解除绑定提示
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
package com.sw.platecabinet.fragment
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.sw.inbound.utils.DateTimeUtils
|
||||
import com.sw.plate.utils.ToastUtils
|
||||
import com.sw.platecabinet.GlobalKey
|
||||
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.response.EquipmentUserInfo
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
@@ -30,6 +34,17 @@ class UnBindPlateFragment private constructor() : BaseFragment<FragmentUnbindPla
|
||||
}
|
||||
}
|
||||
|
||||
private val dialogLauncher = registerForActivityResult(
|
||||
ActivityResultContracts.StartActivityForResult()
|
||||
) { result ->
|
||||
if (result.resultCode == Activity.RESULT_OK) {
|
||||
viewModel.unbindPlate(
|
||||
equipmentBoxCode = info!!.equipmentBoxCode!!,
|
||||
equipmentCode = info!!.equipmentCode!!
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun initialize() {
|
||||
arguments?.let {
|
||||
info = it.getParcelable(ARG_PARAM1)
|
||||
@@ -45,10 +60,11 @@ class UnBindPlateFragment private constructor() : BaseFragment<FragmentUnbindPla
|
||||
}
|
||||
binding.llUnbind.setOnClickListener {
|
||||
if (info == null) return@setOnClickListener
|
||||
viewModel.unbindPlate(
|
||||
equipmentBoxCode = info!!.equipmentBoxCode!!,
|
||||
equipmentCode = info!!.equipmentCode!!
|
||||
)
|
||||
val intent = Intent(requireContext(), UnBindDialogActivity::class.java).apply {
|
||||
putExtra(GlobalKey.PARAM_EQUIPMENT_INFO, info)
|
||||
}
|
||||
dialogLauncher.launch(intent)
|
||||
requireActivity().overridePendingTransition(0, 0)
|
||||
}
|
||||
binding.tvBack.setOnClickListener {
|
||||
activity?.finish()
|
||||
@@ -58,12 +74,15 @@ class UnBindPlateFragment private constructor() : BaseFragment<FragmentUnbindPla
|
||||
override fun registerDataChange() {
|
||||
super.registerDataChange()
|
||||
lifecycleScope.launch {
|
||||
viewModel.bindStateChange.drop(1).collect {
|
||||
viewModel.bindStateChange.collect {
|
||||
if (it.first == null) return@collect // 绑定状态过滤
|
||||
val errorInfo = it.second
|
||||
if (errorInfo.isSuccess()) {
|
||||
ToastUtils.showToast("解绑成功")
|
||||
activity?.finish()
|
||||
// activity?.finish()
|
||||
// 关闭宿主 Activity
|
||||
requireActivity().finish()
|
||||
requireActivity().overridePendingTransition(0, 0)
|
||||
} else {
|
||||
ToastUtils.showToast(errorInfo.msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user