diff --git a/app/src/main/java/com/casic/detector/view/MainActivity.kt b/app/src/main/java/com/casic/detector/view/MainActivity.kt index 4980d91..3bccc59 100644 --- a/app/src/main/java/com/casic/detector/view/MainActivity.kt +++ b/app/src/main/java/com/casic/detector/view/MainActivity.kt @@ -243,6 +243,13 @@ ids.clear() //清空自由巡检添加的Marker aMap.clear() + showLabelsOnMap() + } + + taskViewModel.executeTaskResult.observe(this) { + "工单任务已完成".show(this) + aMap.clear() + showLabelsOnMap() } } @@ -428,9 +435,9 @@ } }).build().show() } else { -// searchDialog.show() + searchDialog.show() //TODO 新探测界面 - searchNewDialog.show() +// searchNewDialog.show() } } @@ -912,7 +919,6 @@ } if (gravity == null || geomagnetic == null) { - Log.d(kTag, "onSensorChanged => 数据不全,不计算") return } @@ -1445,7 +1451,6 @@ private val binding: DialogSearchMarkerBinding by binding() private val decimal by lazy { DecimalFormat("0.0") } private val degreeCache by lazy { HashMap() } - private var isPlaying = false private var markerId = "" private lateinit var searchMarkerTimer: Timer private lateinit var signalTask: TimerTask @@ -1537,21 +1542,9 @@ val energyResponse = hex.take(10).hexToString() val energy = energyResponse.substring(1).toInt() if (energy >= 4000) { - isPlaying = if (!isPlaying) { - soundPool.play(fastSoundResourceId, 1f, 1f, 0, 0, 1f) - true - } else { - soundPool.pause(fastSoundResourceId) - false - } + soundPool.play(fastSoundResourceId, 1f, 1f, 0, 0, 1f) } else { - isPlaying = if (!isPlaying) { - soundPool.play(slowSoundResourceId, 1f, 1f, 0, 0, 1f) - true - } else { - soundPool.pause(slowSoundResourceId) - false - } + soundPool.play(slowSoundResourceId, 1f, 1f, 0, 0, 1f) } binding.resultTextView.text = "信号能量值:${energyResponse}" @@ -1689,7 +1682,6 @@ inner class SearchMarkerNewDialog(context: Context) : Dialog(context) { private val binding: DialogSearchMarkerNewBinding by binding() - private var isPlaying = false private var markerId = "" private lateinit var searchMarkerTimer: Timer private lateinit var signalTask: TimerTask @@ -1761,8 +1753,8 @@ LatLng(it.lat.toDouble(), it.lng.toDouble()) ) - //筛选出距离小于3米的点进行渲染 - if (distance < 3) { + //TODO 筛选出距离小于3米的点进行渲染 + if (distance < 150) { tempPoints.add(it) } } @@ -1829,21 +1821,9 @@ val energyResponse = hex.take(10).hexToString() val energy = energyResponse.substring(1).toInt() if (energy >= 4000) { - isPlaying = if (!isPlaying) { - soundPool.play(fastSoundResourceId, 1f, 1f, 0, 0, 1f) - true - } else { - soundPool.pause(fastSoundResourceId) - false - } + soundPool.play(fastSoundResourceId, 1f, 1f, 0, 0, 1f) } else { - isPlaying = if (!isPlaying) { - soundPool.play(slowSoundResourceId, 1f, 1f, 0, 0, 1f) - true - } else { - soundPool.pause(slowSoundResourceId) - false - } + soundPool.play(slowSoundResourceId, 1f, 1f, 0, 0, 1f) } //通过设置进度条表示能量值 diff --git a/app/src/main/java/com/casic/detector/view/MainActivity.kt b/app/src/main/java/com/casic/detector/view/MainActivity.kt index 4980d91..3bccc59 100644 --- a/app/src/main/java/com/casic/detector/view/MainActivity.kt +++ b/app/src/main/java/com/casic/detector/view/MainActivity.kt @@ -243,6 +243,13 @@ ids.clear() //清空自由巡检添加的Marker aMap.clear() + showLabelsOnMap() + } + + taskViewModel.executeTaskResult.observe(this) { + "工单任务已完成".show(this) + aMap.clear() + showLabelsOnMap() } } @@ -428,9 +435,9 @@ } }).build().show() } else { -// searchDialog.show() + searchDialog.show() //TODO 新探测界面 - searchNewDialog.show() +// searchNewDialog.show() } } @@ -912,7 +919,6 @@ } if (gravity == null || geomagnetic == null) { - Log.d(kTag, "onSensorChanged => 数据不全,不计算") return } @@ -1445,7 +1451,6 @@ private val binding: DialogSearchMarkerBinding by binding() private val decimal by lazy { DecimalFormat("0.0") } private val degreeCache by lazy { HashMap() } - private var isPlaying = false private var markerId = "" private lateinit var searchMarkerTimer: Timer private lateinit var signalTask: TimerTask @@ -1537,21 +1542,9 @@ val energyResponse = hex.take(10).hexToString() val energy = energyResponse.substring(1).toInt() if (energy >= 4000) { - isPlaying = if (!isPlaying) { - soundPool.play(fastSoundResourceId, 1f, 1f, 0, 0, 1f) - true - } else { - soundPool.pause(fastSoundResourceId) - false - } + soundPool.play(fastSoundResourceId, 1f, 1f, 0, 0, 1f) } else { - isPlaying = if (!isPlaying) { - soundPool.play(slowSoundResourceId, 1f, 1f, 0, 0, 1f) - true - } else { - soundPool.pause(slowSoundResourceId) - false - } + soundPool.play(slowSoundResourceId, 1f, 1f, 0, 0, 1f) } binding.resultTextView.text = "信号能量值:${energyResponse}" @@ -1689,7 +1682,6 @@ inner class SearchMarkerNewDialog(context: Context) : Dialog(context) { private val binding: DialogSearchMarkerNewBinding by binding() - private var isPlaying = false private var markerId = "" private lateinit var searchMarkerTimer: Timer private lateinit var signalTask: TimerTask @@ -1761,8 +1753,8 @@ LatLng(it.lat.toDouble(), it.lng.toDouble()) ) - //筛选出距离小于3米的点进行渲染 - if (distance < 3) { + //TODO 筛选出距离小于3米的点进行渲染 + if (distance < 150) { tempPoints.add(it) } } @@ -1829,21 +1821,9 @@ val energyResponse = hex.take(10).hexToString() val energy = energyResponse.substring(1).toInt() if (energy >= 4000) { - isPlaying = if (!isPlaying) { - soundPool.play(fastSoundResourceId, 1f, 1f, 0, 0, 1f) - true - } else { - soundPool.pause(fastSoundResourceId) - false - } + soundPool.play(fastSoundResourceId, 1f, 1f, 0, 0, 1f) } else { - isPlaying = if (!isPlaying) { - soundPool.play(slowSoundResourceId, 1f, 1f, 0, 0, 1f) - true - } else { - soundPool.pause(slowSoundResourceId) - false - } + soundPool.play(slowSoundResourceId, 1f, 1f, 0, 0, 1f) } //通过设置进度条表示能量值 diff --git a/app/src/main/java/com/casic/detector/vm/TaskViewModel.kt b/app/src/main/java/com/casic/detector/vm/TaskViewModel.kt index 800abe7..5bb6eef 100644 --- a/app/src/main/java/com/casic/detector/vm/TaskViewModel.kt +++ b/app/src/main/java/com/casic/detector/vm/TaskViewModel.kt @@ -25,6 +25,7 @@ val taskResult = MutableLiveData() val freeTaskResult = MutableLiveData() val uploadTaskMarkerResult = MutableLiveData() + val executeTaskResult = MutableLiveData() fun createFreeTask(patrollerId: String, description: String) = launch({ val response = RetrofitServiceManager.createFreeTask(patrollerId, description) @@ -158,6 +159,10 @@ //删除本地数据库 DataBaseManager.get.deleteTaskById(taskId) SaveKeyValues.putValue(LocaleConstant.TASK_ID, "") + + val element = JsonParser.parseString(response) + val jsonObject = element.asJsonObject + executeTaskResult.value = jsonObject.get("success").asString } } else { loadState.value = LoadState.Fail