95 lines
3.5 KiB
Kotlin
95 lines
3.5 KiB
Kotlin
//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.ErrorInfo
|
|
//import com.sw.platecabinet.model.response.EquipmentUserInfo
|
|
//import kotlinx.coroutines.launch
|
|
//
|
|
///**
|
|
// * 餐盘柜绑定
|
|
// */
|
|
//class UnBindPlateFragment private constructor() : BaseFragment<FragmentUnbindPlateBinding>(
|
|
// FragmentUnbindPlateBinding::inflate
|
|
//) {
|
|
// internal val ARG_PARAM1 = "param1"
|
|
// private var info: EquipmentUserInfo? = null
|
|
//
|
|
// companion object {
|
|
// @JvmStatic
|
|
// fun newInstance(param1: EquipmentUserInfo?) =
|
|
// UnBindPlateFragment().apply {
|
|
// arguments = Bundle().apply {
|
|
// putParcelable(ARG_PARAM1, param1)
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// private val dialogLauncher = registerForActivityResult(
|
|
// ActivityResultContracts.StartActivityForResult()
|
|
// ) { result ->
|
|
// if (result.resultCode == Activity.RESULT_OK) {
|
|
// viewModel.unbindPlate(info?.id) { pair ->
|
|
// updateBindState(pair)
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// override fun initialize() {
|
|
// arguments?.let { args ->
|
|
// info = args.getParcelable(ARG_PARAM1)
|
|
// info?.let {
|
|
// binding.tvNum.text = "${it.equipmentName}-${it.equipmentBoxCode}"
|
|
// binding.tvPlateNumberValue.text = it.plateNumber
|
|
// binding.tvNameValue.text = it.name.maskName()
|
|
// binding.tvPhoneValue.text = it.phone.maskPhone()
|
|
// val timeInfo = DateTimeUtils.parseDateTime(it.updateTime)
|
|
// val timeAgo = DateTimeUtils.getTimeAgo(timeInfo)
|
|
// binding.tvUpdateTimeValue.text = timeAgo
|
|
// }
|
|
// }
|
|
// binding.llUnbind.setOnClickListener {
|
|
// if (info == null) return@setOnClickListener
|
|
// 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()
|
|
// }
|
|
// }
|
|
//
|
|
// override fun registerDataChange() {
|
|
// super.registerDataChange()
|
|
//// 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)
|
|
// }
|
|
// }
|
|
//} |