水枪设置1
This commit is contained in:
@@ -22,8 +22,6 @@ import kotlinx.coroutines.withContext
|
||||
class SettingsActivity : BaseActivity() {
|
||||
|
||||
private lateinit var binding: SettingsActivityBinding
|
||||
private val SP_NAME = "DeviceSettings"
|
||||
private val KEY_RECOGNITION_MODE = "recognition_mode"
|
||||
private var alertAudio: String? = null
|
||||
private var audioContent: String? = null
|
||||
|
||||
@@ -82,7 +80,43 @@ class SettingsActivity : BaseActivity() {
|
||||
}
|
||||
binding.itemWaterGunSetting.setOnClickListener {
|
||||
val intent = Intent(this, WaterGunSettingsActivity::class.java)
|
||||
startActivity(intent)
|
||||
// 传递水枪设置参数
|
||||
val deviceId = DeviceIdEvent.getDeviceId()
|
||||
if (!deviceId.isNullOrEmpty()) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
try {
|
||||
val response = RetrofitNetwork.getNetworkService().getDeviceInfo(deviceId)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (response.code == 200 && response.data != null) {
|
||||
val device = response.data
|
||||
intent.putExtra("strikeRange", device.strikeRange ?: "7")
|
||||
intent.putExtra("strikeInterval", device.strikeInterval ?: "3")
|
||||
intent.putExtra("container", device.container ?: "容器4")
|
||||
startActivity(intent)
|
||||
} else {
|
||||
// 如果获取失败,使用默认值
|
||||
intent.putExtra("strikeRange", "7")
|
||||
intent.putExtra("strikeInterval", "3")
|
||||
intent.putExtra("container", "容器4")
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
withContext(Dispatchers.Main) {
|
||||
intent.putExtra("strikeRange", "7")
|
||||
intent.putExtra("strikeInterval", "3")
|
||||
intent.putExtra("container", "容器4")
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
intent.putExtra("strikeRange", "7")
|
||||
intent.putExtra("strikeInterval", "3")
|
||||
intent.putExtra("container", "容器4")
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
binding.itemAutoMode.setOnClickListener {
|
||||
val intent = Intent(this, AutoModeActivity::class.java)
|
||||
|
||||
Reference in New Issue
Block a user