|
|
@@ -9,10 +9,9 @@ import androidx.core.view.isVisible
|
|
|
import androidx.lifecycle.ViewModelProvider
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.grkj.iscs.R
|
|
|
-import com.grkj.iscs.databinding.FragmentDeviceInputKeyAndLockBinding
|
|
|
+import com.grkj.iscs.databinding.FragmentDeviceRegistrationKeyAndLockBinding
|
|
|
import com.grkj.iscs.extentions.setSelected
|
|
|
import com.grkj.iscs.extentions.setVisibleWithHolder
|
|
|
-import com.grkj.iscs.modbus.DockBean
|
|
|
import com.grkj.iscs.modbus.ModBusController
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_KEY
|
|
|
import com.grkj.iscs.model.DeviceConst.DOCK_TYPE_LOCK
|
|
|
@@ -23,7 +22,7 @@ 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.dialog.TipDialog
|
|
|
-import com.grkj.iscs.view.viewmodel.DeviceInputKeyAndLockViewModel
|
|
|
+import com.grkj.iscs.view.viewmodel.DeviceRegistrationKeyAndLockViewModel
|
|
|
import com.sik.sikcore.extension.setDebouncedClickListener
|
|
|
import com.sik.sikcore.thread.ThreadUtils
|
|
|
import com.zhy.adapter.recyclerview.CommonAdapter
|
|
|
@@ -37,18 +36,17 @@ import kotlinx.coroutines.withContext
|
|
|
/**
|
|
|
* 新硬件录入页
|
|
|
*/
|
|
|
-class DeviceInputKeyAndLockFragment :
|
|
|
- BaseNavFragment<FragmentDeviceInputKeyAndLockBinding>() {
|
|
|
- private val viewModel: DeviceInputKeyAndLockViewModel by lazy { ViewModelProvider(this)[DeviceInputKeyAndLockViewModel::class] }
|
|
|
+class DeviceRegistrationKeyAndLockFragment :
|
|
|
+ BaseNavFragment<FragmentDeviceRegistrationKeyAndLockBinding>() {
|
|
|
+ private val viewModel: DeviceRegistrationKeyAndLockViewModel by lazy { ViewModelProvider(this)[DeviceRegistrationKeyAndLockViewModel::class] }
|
|
|
private val tipDialog: TipDialog by lazy { TipDialog(requireContext()) }
|
|
|
private var mRowList = mutableListOf<DockStatusBO>()
|
|
|
private var isAlreadyInput: Boolean = false
|
|
|
override fun getLayoutId(): Int {
|
|
|
- return R.layout.fragment_device_input_key_and_lock
|
|
|
+ return R.layout.fragment_device_registration_key_and_lock
|
|
|
}
|
|
|
|
|
|
override fun initView() {
|
|
|
- ISCSDomainData.isDeviceEnter = true
|
|
|
viewModel.loginUser = SPUtils.getLoginUser(requireContext())
|
|
|
//打开所有钥匙仓并关闭充电
|
|
|
LogUtil.d("设备录入-打开所有钥匙仓并关闭充电")
|
|
|
@@ -64,7 +62,11 @@ class DeviceInputKeyAndLockFragment :
|
|
|
binding.scanTip.isVisible = !it
|
|
|
binding.rvDockLayout.isVisible = it
|
|
|
binding.cbRescanOrInput.isVisible = it
|
|
|
- binding.scanResultTip.text = requireContext().getString(R.string.device_input_scan_result_tip,viewModel.newHardwareKeySize,viewModel.newHardwareLockSize)
|
|
|
+ binding.scanResultTip.text = requireContext().getString(
|
|
|
+ R.string.device_registration_scan_result_tip,
|
|
|
+ viewModel.newHardwareKeySize,
|
|
|
+ viewModel.newHardwareLockSize
|
|
|
+ )
|
|
|
}
|
|
|
binding.cbRescanOrInput.setDebouncedClickListener {
|
|
|
if (isAlreadyInput) {
|
|
|
@@ -75,7 +77,8 @@ class DeviceInputKeyAndLockFragment :
|
|
|
isAlreadyInput = false
|
|
|
binding.cbRescanOrInput.setText(
|
|
|
if (isAlreadyInput) CommonUtils.getStr(R.string.rescan)
|
|
|
- .toString() else CommonUtils.getStr(R.string.input_to_system).toString()
|
|
|
+ .toString() else CommonUtils.getStr(R.string.registration_to_system)
|
|
|
+ .toString()
|
|
|
)
|
|
|
} else {
|
|
|
viewModel.deviceInputData(mRowList).observe(this) {
|
|
|
@@ -83,13 +86,13 @@ class DeviceInputKeyAndLockFragment :
|
|
|
isAlreadyInput = true
|
|
|
binding.cbRescanOrInput.setText(
|
|
|
if (isAlreadyInput) CommonUtils.getStr(R.string.rescan)
|
|
|
- .toString() else CommonUtils.getStr(R.string.input_to_system)
|
|
|
+ .toString() else CommonUtils.getStr(R.string.registration_to_system)
|
|
|
.toString()
|
|
|
)
|
|
|
tipDialog.setType(TipDialog.TYPE_CONFIRM)
|
|
|
tipDialog.setTip(
|
|
|
requireContext().getString(
|
|
|
- R.string.already_input_device_tip,
|
|
|
+ R.string.already_registration_device_tip,
|
|
|
it.second,
|
|
|
it.third
|
|
|
)
|
|
|
@@ -98,7 +101,7 @@ class DeviceInputKeyAndLockFragment :
|
|
|
} else {
|
|
|
tipDialog.setType(TipDialog.TYPE_ALL)
|
|
|
tipDialog.setTip(
|
|
|
- requireContext().getString(R.string.input_device_error)
|
|
|
+ requireContext().getString(R.string.registration_device_error)
|
|
|
)
|
|
|
tipDialog.showCancelCountdown(10)
|
|
|
}
|
|
|
@@ -124,7 +127,7 @@ class DeviceInputKeyAndLockFragment :
|
|
|
fun refreshAdapter() {
|
|
|
binding.cbRescanOrInput.setText(
|
|
|
if (isAlreadyInput) CommonUtils.getStr(R.string.rescan)
|
|
|
- .toString() else CommonUtils.getStr(R.string.input_to_system).toString()
|
|
|
+ .toString() else CommonUtils.getStr(R.string.registration_to_system).toString()
|
|
|
)
|
|
|
ThreadUtils.runOnIO {
|
|
|
if (isResumed) {
|
|
|
@@ -143,7 +146,7 @@ class DeviceInputKeyAndLockFragment :
|
|
|
}
|
|
|
|
|
|
override fun onDestroyView() {
|
|
|
- ISCSDomainData.isDeviceEnter = false
|
|
|
+ ISCSDomainData.isDeviceRegistration = false
|
|
|
viewModel.unregisterInitListener()
|
|
|
viewModel.isDestroy = true
|
|
|
super.onDestroyView()
|
|
|
@@ -151,7 +154,7 @@ class DeviceInputKeyAndLockFragment :
|
|
|
|
|
|
class KeyDockItemDelegate(
|
|
|
var context: Context,
|
|
|
- var presenter: DeviceInputKeyAndLockViewModel?
|
|
|
+ var presenter: DeviceRegistrationKeyAndLockViewModel?
|
|
|
) :
|
|
|
ItemViewDelegate<DockStatusBO> {
|
|
|
private val statusCloseTintColor =
|
|
|
@@ -275,7 +278,7 @@ class DeviceInputKeyAndLockFragment :
|
|
|
|
|
|
class LockDockItemDelegate(
|
|
|
var context: Context,
|
|
|
- var presenter: DeviceInputKeyAndLockViewModel?,
|
|
|
+ var presenter: DeviceRegistrationKeyAndLockViewModel?,
|
|
|
var ctx: Context
|
|
|
) : ItemViewDelegate<DockStatusBO> {
|
|
|
private val statusCloseTintColor =
|