调整了餐盘柜3种情况处理
This commit is contained in:
@@ -13,6 +13,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.sw.plate.utils.ToastUtils
|
||||
import com.sw.platecabinet.R
|
||||
import com.sw.platecabinet.activity.MainActivity
|
||||
import com.sw.platecabinet.activity.PageType
|
||||
import com.sw.platecabinet.adapter.GenericItemAdapter
|
||||
import com.sw.platecabinet.adapter.GridSpacingItemDecoration
|
||||
import com.sw.platecabinet.adapter.dpToPx
|
||||
@@ -34,24 +35,24 @@ class BindPlateFragment : BaseFragment<FragmentBindPlateBinding>(
|
||||
FragmentBindPlateBinding::inflate
|
||||
) {
|
||||
private lateinit var adapter: GenericItemAdapter<SearchResult.Member, ItemSearchUserInfoBinding>
|
||||
internal val ARG_PARAM1 = "param1"
|
||||
internal val KEY_ACTION_TYPE = "actionType"
|
||||
private var info: EquipmentUserInfo? = null
|
||||
private var checkedItem: SearchResult.Member? = null
|
||||
private var lastText = ""
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(param1: EquipmentUserInfo?) =
|
||||
fun newInstance(userInfo: EquipmentUserInfo?) =
|
||||
BindPlateFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(ARG_PARAM1, param1)
|
||||
putParcelable(KEY_ACTION_TYPE, userInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun initialize() {
|
||||
arguments?.let {
|
||||
info = it.getParcelable(ARG_PARAM1)
|
||||
info = it.getParcelable(KEY_ACTION_TYPE)
|
||||
info?.let {
|
||||
binding.tvNum.text = "${it.equipmentName}-${it.equipmentBoxCode}"
|
||||
if (!TextUtils.isEmpty(it.plateNumber)) {
|
||||
@@ -175,8 +176,16 @@ class BindPlateFragment : BaseFragment<FragmentBindPlateBinding>(
|
||||
if (it.first == null) return@collect // 解绑状态过滤
|
||||
val errorInfo = it.second
|
||||
if (errorInfo.isSuccess()) {
|
||||
ToastUtils.showToast("绑定成功")
|
||||
activity?.finish()
|
||||
if (errorInfo.equipmentUserInfo?.isOtherEquipment() == true) {
|
||||
MainActivity.start(
|
||||
requireContext(),
|
||||
pageType = PageType.PLATE_TIP,
|
||||
equipmentUserInfo = errorInfo.equipmentUserInfo
|
||||
)
|
||||
} else {
|
||||
ToastUtils.showToast("绑定成功")
|
||||
activity?.finish()
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showToast(errorInfo.msg)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sw.platecabinet.fragment
|
||||
|
||||
import android.os.CountDownTimer
|
||||
import com.sw.platecabinet.Constants
|
||||
import com.sw.platecabinet.databinding.FragmentPlateCabinetFullBinding
|
||||
import timber.log.Timber
|
||||
|
||||
@@ -9,7 +10,7 @@ import timber.log.Timber
|
||||
*/
|
||||
class PlateCabinetFullFragment :
|
||||
BaseFragment<FragmentPlateCabinetFullBinding>(FragmentPlateCabinetFullBinding::inflate) {
|
||||
private var totalTimeInMillis: Long = 5 * 1000
|
||||
private var totalTimeInMillis: Long = Constants.AUTO_CLOSE_TIME * 1000
|
||||
|
||||
override fun initialize() {
|
||||
Timber.d("initialize")
|
||||
|
||||
@@ -1,16 +1,54 @@
|
||||
package com.sw.platecabinet.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import com.sw.platecabinet.Constants
|
||||
import com.sw.platecabinet.R
|
||||
import com.sw.platecabinet.databinding.FragmentPlateOpenBinding
|
||||
import com.sw.platecabinet.model.response.EquipmentUserInfo
|
||||
|
||||
/**
|
||||
* 餐盘柜打开界面
|
||||
* 餐盘柜提示界面
|
||||
*/
|
||||
class PlateOpenFragment :
|
||||
BaseFragment<FragmentPlateOpenBinding>(FragmentPlateOpenBinding::inflate) {
|
||||
private var totalTimeInMillis: Long = 5 * 1000
|
||||
private var totalTimeInMillis: Long = Constants.AUTO_CLOSE_TIME * 1000
|
||||
internal val KEY_ACTION_TYPE = "actionType"
|
||||
private var info: EquipmentUserInfo? = null
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(userInfo: EquipmentUserInfo?) =
|
||||
PlateOpenFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(KEY_ACTION_TYPE, userInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun initialize() {
|
||||
arguments?.let {
|
||||
info = it.getParcelable(KEY_ACTION_TYPE)
|
||||
info?.let {
|
||||
if (!it.isBound()) {
|
||||
binding.ivType.setImageResource(R.drawable.ic_tip_warn)
|
||||
binding.tvTitle.text = "暂无餐盘信息"
|
||||
binding.tvSubTitle.text = "请联系管理员"
|
||||
binding.tvTitle.setTextColor(requireContext().getColor(R.color.tip_title_fail))
|
||||
} else if (it.isOtherEquipment()) {
|
||||
binding.ivType.setImageResource(R.drawable.ic_tip_warn)
|
||||
binding.tvTitle.text = "暂无餐盘信息"
|
||||
binding.tvSubTitle.text = "您的餐盘绑定在${it.equipmentName ?: " "}号柜上"
|
||||
binding.tvTitle.setTextColor(requireContext().getColor(R.color.tip_title_fail))
|
||||
} else {
|
||||
binding.ivType.setImageResource(R.drawable.ic_tip_success)
|
||||
binding.tvTitle.text = "柜门开启"
|
||||
binding.tvSubTitle.text = "餐盘取出后请关闭柜门"
|
||||
binding.tvTitle.setTextColor(requireContext().getColor(R.color.tip_title_success))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initCountTime()
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ class SettingListFragment :
|
||||
SerialApi.openPlate(equipmentBoxCode, object : SerialPortManager.SendCallback {
|
||||
override fun onSuccess() {
|
||||
hideWaitingDialog()
|
||||
MainActivity.start(requireContext(), pageType = PageType.PLATE_OPEN)
|
||||
MainActivity.start(requireContext(), pageType = PageType.PLATE_TIP)
|
||||
}
|
||||
|
||||
override fun onFail(e: Exception?) {
|
||||
|
||||
Reference in New Issue
Block a user