|
@@ -12,15 +12,18 @@ import com.grkj.iscs.R
|
|
|
import com.grkj.iscs.databinding.FragmentDeviceInputKeyAndLockBinding
|
|
import com.grkj.iscs.databinding.FragmentDeviceInputKeyAndLockBinding
|
|
|
import com.grkj.iscs.extentions.setSelected
|
|
import com.grkj.iscs.extentions.setSelected
|
|
|
import com.grkj.iscs.extentions.setVisibleWithHolder
|
|
import com.grkj.iscs.extentions.setVisibleWithHolder
|
|
|
|
|
+import com.grkj.iscs.modbus.DockBean
|
|
|
import com.grkj.iscs.modbus.ModBusController
|
|
import com.grkj.iscs.modbus.ModBusController
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_KEY
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_KEY
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_LOCK
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_LOCK
|
|
|
|
|
+import com.grkj.iscs.model.ISCSDomainData
|
|
|
import com.grkj.iscs.model.bo.DockStatusBO
|
|
import com.grkj.iscs.model.bo.DockStatusBO
|
|
|
import com.grkj.iscs.util.CommonUtils
|
|
import com.grkj.iscs.util.CommonUtils
|
|
|
import com.grkj.iscs.util.SPUtils
|
|
import com.grkj.iscs.util.SPUtils
|
|
|
|
|
+import com.grkj.iscs.util.log.LogUtil
|
|
|
import com.grkj.iscs.view.base.BaseNavFragment
|
|
import com.grkj.iscs.view.base.BaseNavFragment
|
|
|
import com.grkj.iscs.view.dialog.TipDialog
|
|
import com.grkj.iscs.view.dialog.TipDialog
|
|
|
-import com.grkj.iscs.view.presenter.DeviceInputKeyAndLockViewModel
|
|
|
|
|
|
|
+import com.grkj.iscs.view.viewmodel.DeviceInputKeyAndLockViewModel
|
|
|
import com.sik.sikcore.extension.setDebouncedClickListener
|
|
import com.sik.sikcore.extension.setDebouncedClickListener
|
|
|
import com.sik.sikcore.thread.ThreadUtils
|
|
import com.sik.sikcore.thread.ThreadUtils
|
|
|
import com.zhy.adapter.recyclerview.CommonAdapter
|
|
import com.zhy.adapter.recyclerview.CommonAdapter
|
|
@@ -45,18 +48,29 @@ class DeviceInputKeyAndLockFragment :
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun initView() {
|
|
override fun initView() {
|
|
|
|
|
+ ISCSDomainData.isDeviceEnter = true
|
|
|
viewModel.loginUser = SPUtils.getLoginUser(requireContext())
|
|
viewModel.loginUser = SPUtils.getLoginUser(requireContext())
|
|
|
|
|
+ //打开所有钥匙仓并关闭充电
|
|
|
|
|
+ LogUtil.d("设备录入-打开所有钥匙仓并关闭充电")
|
|
|
|
|
+ ModBusController.controlAllKeyBuckleOpen()
|
|
|
|
|
+ viewModel.registerInitListener().observe(this) {
|
|
|
|
|
+ LogUtil.d("设备录入-初始化检测完成")
|
|
|
|
|
+ }
|
|
|
viewModel.initData(mRowList)
|
|
viewModel.initData(mRowList)
|
|
|
binding.cbBack.setDebouncedClickListener {
|
|
binding.cbBack.setDebouncedClickListener {
|
|
|
navController.popBackStack()
|
|
navController.popBackStack()
|
|
|
}
|
|
}
|
|
|
|
|
+ viewModel.isLoadComplete.observe(this) {
|
|
|
|
|
+ binding.scanTip.isVisible = !it
|
|
|
|
|
+ binding.rvDock.isVisible = it
|
|
|
|
|
+ binding.cbRescanOrInput.isVisible = it
|
|
|
|
|
+ }
|
|
|
binding.cbRescanOrInput.setDebouncedClickListener {
|
|
binding.cbRescanOrInput.setDebouncedClickListener {
|
|
|
if (isAlreadyInput) {
|
|
if (isAlreadyInput) {
|
|
|
mRowList.clear()
|
|
mRowList.clear()
|
|
|
|
|
+ viewModel.isStartCheckKey = false
|
|
|
|
|
+ viewModel.isLoadComplete.postValue(false)
|
|
|
viewModel.initData(mRowList)
|
|
viewModel.initData(mRowList)
|
|
|
- binding.scanTip.isVisible = mRowList.isEmpty()
|
|
|
|
|
- binding.rvDock.isVisible = mRowList.isNotEmpty()
|
|
|
|
|
- binding.cbRescanOrInput.isVisible = binding.rvDock.isVisible
|
|
|
|
|
isAlreadyInput = false
|
|
isAlreadyInput = false
|
|
|
binding.cbRescanOrInput.setText(
|
|
binding.cbRescanOrInput.setText(
|
|
|
if (isAlreadyInput) CommonUtils.getStr(R.string.rescan)
|
|
if (isAlreadyInput) CommonUtils.getStr(R.string.rescan)
|
|
@@ -107,9 +121,6 @@ class DeviceInputKeyAndLockFragment :
|
|
|
override fun onResume() {
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
super.onResume()
|
|
|
fun refreshAdapter() {
|
|
fun refreshAdapter() {
|
|
|
- binding.scanTip.isVisible = mRowList.isEmpty()
|
|
|
|
|
- binding.rvDock.isVisible = mRowList.isNotEmpty()
|
|
|
|
|
- binding.cbRescanOrInput.isVisible = binding.rvDock.isVisible
|
|
|
|
|
binding.cbRescanOrInput.setText(
|
|
binding.cbRescanOrInput.setText(
|
|
|
if (isAlreadyInput) CommonUtils.getStr(R.string.rescan)
|
|
if (isAlreadyInput) CommonUtils.getStr(R.string.rescan)
|
|
|
.toString() else CommonUtils.getStr(R.string.input_to_system).toString()
|
|
.toString() else CommonUtils.getStr(R.string.input_to_system).toString()
|
|
@@ -120,7 +131,9 @@ class DeviceInputKeyAndLockFragment :
|
|
|
binding.rvDock?.adapter?.notifyDataSetChanged()
|
|
binding.rvDock?.adapter?.notifyDataSetChanged()
|
|
|
}
|
|
}
|
|
|
delay(1000)
|
|
delay(1000)
|
|
|
- refreshAdapter()
|
|
|
|
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
|
|
+ refreshAdapter()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -128,6 +141,13 @@ class DeviceInputKeyAndLockFragment :
|
|
|
refreshAdapter()
|
|
refreshAdapter()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ override fun onDestroyView() {
|
|
|
|
|
+ ISCSDomainData.isDeviceEnter = false
|
|
|
|
|
+ viewModel.unregisterInitListener()
|
|
|
|
|
+ viewModel.isDestroy = true
|
|
|
|
|
+ super.onDestroyView()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
class KeyDockItemDelegate(
|
|
class KeyDockItemDelegate(
|
|
|
var context: Context,
|
|
var context: Context,
|
|
|
var presenter: DeviceInputKeyAndLockViewModel?
|
|
var presenter: DeviceInputKeyAndLockViewModel?
|
|
@@ -161,6 +181,38 @@ class DeviceInputKeyAndLockFragment :
|
|
|
R.id.iv_key_4,
|
|
R.id.iv_key_4,
|
|
|
ModBusController.isKeyExist(row.dockList.find { it.column == "2" }?.address, false)
|
|
ModBusController.isKeyExist(row.dockList.find { it.column == "2" }?.address, false)
|
|
|
)
|
|
)
|
|
|
|
|
+ holder?.getView<TextView>(R.id.tv_new_device_mac_1)?.apply {
|
|
|
|
|
+ val keyBean = ModBusController.getKeyByDock(
|
|
|
|
|
+ row.dockList.find { it.column == "1" }?.address,
|
|
|
|
|
+ true
|
|
|
|
|
+ )?.mac
|
|
|
|
|
+ isVisible = !keyBean.isNullOrEmpty()
|
|
|
|
|
+ text = keyBean
|
|
|
|
|
+ }
|
|
|
|
|
+ holder?.getView<TextView>(R.id.tv_new_device_mac_2)?.apply {
|
|
|
|
|
+ val keyBean = ModBusController.getKeyByDock(
|
|
|
|
|
+ row.dockList.find { it.column == "1" }?.address,
|
|
|
|
|
+ false
|
|
|
|
|
+ )?.mac
|
|
|
|
|
+ isVisible = !keyBean.isNullOrEmpty()
|
|
|
|
|
+ text = keyBean
|
|
|
|
|
+ }
|
|
|
|
|
+ holder?.getView<TextView>(R.id.tv_new_device_mac_3)?.apply {
|
|
|
|
|
+ val keyBean = ModBusController.getKeyByDock(
|
|
|
|
|
+ row.dockList.find { it.column == "2" }?.address,
|
|
|
|
|
+ true
|
|
|
|
|
+ )?.mac
|
|
|
|
|
+ isVisible = !keyBean.isNullOrEmpty()
|
|
|
|
|
+ text = keyBean
|
|
|
|
|
+ }
|
|
|
|
|
+ holder?.getView<TextView>(R.id.tv_new_device_mac_4)?.apply {
|
|
|
|
|
+ val keyBean = ModBusController.getKeyByDock(
|
|
|
|
|
+ row.dockList.find { it.column == "2" }?.address,
|
|
|
|
|
+ false
|
|
|
|
|
+ )?.mac
|
|
|
|
|
+ isVisible = !keyBean.isNullOrEmpty()
|
|
|
|
|
+ text = keyBean
|
|
|
|
|
+ }
|
|
|
// holder?.getView<View>(R.id.v_buckle_status_1)?.backgroundTintList =
|
|
// holder?.getView<View>(R.id.v_buckle_status_1)?.backgroundTintList =
|
|
|
// if (presenter?.getKeyBuckleLockEnabled(
|
|
// if (presenter?.getKeyBuckleLockEnabled(
|
|
|
// row.dockList.find { it.column == "1" }?.address,
|
|
// row.dockList.find { it.column == "1" }?.address,
|