|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.yinuo.safetywatcher.watcher.ui
|
|
|
|
|
|
|
|
|
|
import android.view.KeyEvent
|
|
|
|
|
import android.view.View
|
|
|
|
|
import com.yinuo.safetywatcher.R
|
|
|
|
|
import com.yinuo.safetywatcher.databinding.ActivitySensorThresholdBinding
|
|
|
|
@ -9,6 +10,7 @@ import com.yinuo.safetywatcher.watcher.port.getGasLowThreshold
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.getLocalGasUnit
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.saveHighThreshold
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.port.saveLowThreshold
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.showIme
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.showToast
|
|
|
|
|
|
|
|
|
|
class SensorThresholdSetActivity : NoOptionsActivity() {
|
|
|
|
@ -46,6 +48,50 @@ class SensorThresholdSetActivity : NoOptionsActivity() {
|
|
|
|
|
saveData()
|
|
|
|
|
showToast("保存成功")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setListener()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun setListener() {
|
|
|
|
|
mBinding.etMin.setOnKeyListener { _, keyCode, event ->
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
tryFocusBackArea()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
mBinding.etMax.requestFocus()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
mBinding.etMin.showIme()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return@setOnKeyListener false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mBinding.etMax.setOnKeyListener { _, keyCode, event ->
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
mBinding.etMin.requestFocus()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
mBinding.tvSave.requestFocus()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
} else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
|
|
|
|
|
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
|
|
|
mBinding.etMax.showIme()
|
|
|
|
|
return@setOnKeyListener true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return@setOnKeyListener false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun saveData() {
|
|
|
|
|