diff --git a/.gitignore b/.gitignore index e895293..5a35d83 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ local.properties /app/build -/app/release \ No newline at end of file +/app/release +*.zip \ No newline at end of file diff --git a/.gitignore b/.gitignore index e895293..5a35d83 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ local.properties /app/build -/app/release \ No newline at end of file +/app/release +*.zip \ No newline at end of file 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 ced95b2..10de5fc 100644 --- a/app/src/main/java/com/casic/detector/view/MainActivity.kt +++ b/app/src/main/java/com/casic/detector/view/MainActivity.kt @@ -557,8 +557,13 @@ //显示标识器详细信息 if (!detailDialog.isShowing) { - detailDialog.setMarkerId(markerId) - detailDialog.show() + val labelBean = DataBaseManager.get.queryLabelById(markerId).firstOrNull() + if (labelBean == null) { + "无法查询到此ID【${markerId}】的信息".show(context) + } else { + detailDialog.setMarker(labelBean) + detailDialog.show() + } } } @@ -566,7 +571,7 @@ val energyResponse = hex.take(10).hexToString() try { val energy = energyResponse.substring(1).toInt() - if (energy <= 500) { + if (energy <= 500 && detailDialog.isShowing) { detailDialog.dismiss() } } catch (e: NumberFormatException) { diff --git a/.gitignore b/.gitignore index e895293..5a35d83 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ local.properties /app/build -/app/release \ No newline at end of file +/app/release +*.zip \ No newline at end of file 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 ced95b2..10de5fc 100644 --- a/app/src/main/java/com/casic/detector/view/MainActivity.kt +++ b/app/src/main/java/com/casic/detector/view/MainActivity.kt @@ -557,8 +557,13 @@ //显示标识器详细信息 if (!detailDialog.isShowing) { - detailDialog.setMarkerId(markerId) - detailDialog.show() + val labelBean = DataBaseManager.get.queryLabelById(markerId).firstOrNull() + if (labelBean == null) { + "无法查询到此ID【${markerId}】的信息".show(context) + } else { + detailDialog.setMarker(labelBean) + detailDialog.show() + } } } @@ -566,7 +571,7 @@ val energyResponse = hex.take(10).hexToString() try { val energy = energyResponse.substring(1).toInt() - if (energy <= 500) { + if (energy <= 500 && detailDialog.isShowing) { detailDialog.dismiss() } } catch (e: NumberFormatException) { diff --git a/app/src/main/java/com/casic/detector/widgets/MarkerDetailDialog.kt b/app/src/main/java/com/casic/detector/widgets/MarkerDetailDialog.kt index be97c4c..56f4d9b 100644 --- a/app/src/main/java/com/casic/detector/widgets/MarkerDetailDialog.kt +++ b/app/src/main/java/com/casic/detector/widgets/MarkerDetailDialog.kt @@ -6,8 +6,8 @@ import android.graphics.drawable.ColorDrawable import android.os.Bundle import com.casic.detector.R +import com.casic.detector.bean.LabelBean import com.casic.detector.databinding.DialogMarkerDetailBinding -import com.casic.detector.utils.DataBaseManager import com.casic.detector.utils.LocaleConstant import com.pengxh.kt.lite.extensions.binding import com.pengxh.kt.lite.extensions.getScreenHeight @@ -16,10 +16,10 @@ class MarkerDetailDialog constructor(context: Context) : Dialog(context, R.style.UserDefinedDialogStyle) { - private lateinit var markerId: String + private lateinit var labelBean: LabelBean - fun setMarkerId(markerId: String) { - this.markerId = markerId + fun setMarker(labelBean: LabelBean) { + this.labelBean = labelBean } private val binding: DialogMarkerDetailBinding by binding() @@ -39,7 +39,6 @@ this.initDialogLayoutParams() setCanceledOnTouchOutside(true) - val labelBean = DataBaseManager.get.queryLabelById(markerId).firstOrNull() ?: return binding.objectTypeView.text = LocaleConstant.POINT_TYPE_ARRAY[labelBean.objectType.toInt() - 1] binding.pipelineTypeView.text = labelBean.pipelineType