diff --git a/app/build.gradle b/app/build.gradle index b9e1ce2..b3cd0c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ defaultConfig { applicationId "com.casic.detector" - minSdkVersion 23 + minSdkVersion 22 targetSdkVersion 32 versionCode 1 versionName "1.0.0.0" @@ -44,7 +44,7 @@ applicationVariants.all { variant -> variant.outputs.all { - outputFileName = "TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + outputFileName = "COM_TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" } } diff --git a/app/build.gradle b/app/build.gradle index b9e1ce2..b3cd0c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ defaultConfig { applicationId "com.casic.detector" - minSdkVersion 23 + minSdkVersion 22 targetSdkVersion 32 versionCode 1 versionName "1.0.0.0" @@ -44,7 +44,7 @@ applicationVariants.all { variant -> variant.outputs.all { - outputFileName = "TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + outputFileName = "COM_TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" } } diff --git a/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt b/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt index 271e9a1..581b66c 100644 --- a/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt +++ b/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt @@ -29,6 +29,20 @@ return labelBeanDao.loadAll() } + fun loadLabelByCondition(selectedItem: String, value: String): MutableList { + val property = when (selectedItem) { + LocaleConstant.SPINNER_ARRAY[0] -> LabelBeanDao.Properties.IdentifierId + LocaleConstant.SPINNER_ARRAY[1] -> LabelBeanDao.Properties.Area + LocaleConstant.SPINNER_ARRAY[2] -> LabelBeanDao.Properties.Line + LocaleConstant.SPINNER_ARRAY[3] -> LabelBeanDao.Properties.Road + LocaleConstant.SPINNER_ARRAY[4] -> LabelBeanDao.Properties.Owner + LocaleConstant.SPINNER_ARRAY[5] -> LabelBeanDao.Properties.Person + LocaleConstant.SPINNER_ARRAY[6] -> LabelBeanDao.Properties.InstallTime + else -> LabelBeanDao.Properties.Remark + } + return labelBeanDao.queryBuilder().where(property.eq(value)).list() + } + fun queryLabelById(identifierId: String): List { return labelBeanDao.queryBuilder() .where(LabelBeanDao.Properties.IdentifierId.eq(identifierId)) diff --git a/app/build.gradle b/app/build.gradle index b9e1ce2..b3cd0c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ defaultConfig { applicationId "com.casic.detector" - minSdkVersion 23 + minSdkVersion 22 targetSdkVersion 32 versionCode 1 versionName "1.0.0.0" @@ -44,7 +44,7 @@ applicationVariants.all { variant -> variant.outputs.all { - outputFileName = "TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + outputFileName = "COM_TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" } } diff --git a/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt b/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt index 271e9a1..581b66c 100644 --- a/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt +++ b/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt @@ -29,6 +29,20 @@ return labelBeanDao.loadAll() } + fun loadLabelByCondition(selectedItem: String, value: String): MutableList { + val property = when (selectedItem) { + LocaleConstant.SPINNER_ARRAY[0] -> LabelBeanDao.Properties.IdentifierId + LocaleConstant.SPINNER_ARRAY[1] -> LabelBeanDao.Properties.Area + LocaleConstant.SPINNER_ARRAY[2] -> LabelBeanDao.Properties.Line + LocaleConstant.SPINNER_ARRAY[3] -> LabelBeanDao.Properties.Road + LocaleConstant.SPINNER_ARRAY[4] -> LabelBeanDao.Properties.Owner + LocaleConstant.SPINNER_ARRAY[5] -> LabelBeanDao.Properties.Person + LocaleConstant.SPINNER_ARRAY[6] -> LabelBeanDao.Properties.InstallTime + else -> LabelBeanDao.Properties.Remark + } + return labelBeanDao.queryBuilder().where(property.eq(value)).list() + } + fun queryLabelById(identifierId: String): List { return labelBeanDao.queryBuilder() .where(LabelBeanDao.Properties.IdentifierId.eq(identifierId)) diff --git a/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt b/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt index b5aad2a..9fb1c87 100644 --- a/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt @@ -28,4 +28,5 @@ val POPUP_TITLES = arrayOf("更新数据", "下载工单", "关于软件", "事件上报", "标识器补全") var POINT_TYPE_ARRAY = arrayOf("", "管线", "管线附属物", "管线特征管点", "交叉穿越点") + var SPINNER_ARRAY = arrayOf("标识器ID", "所属区域", "所属线路", "所属道路", "权属单位", "安装部门", "安装时间", "备注") } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index b9e1ce2..b3cd0c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ defaultConfig { applicationId "com.casic.detector" - minSdkVersion 23 + minSdkVersion 22 targetSdkVersion 32 versionCode 1 versionName "1.0.0.0" @@ -44,7 +44,7 @@ applicationVariants.all { variant -> variant.outputs.all { - outputFileName = "TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + outputFileName = "COM_TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" } } diff --git a/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt b/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt index 271e9a1..581b66c 100644 --- a/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt +++ b/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt @@ -29,6 +29,20 @@ return labelBeanDao.loadAll() } + fun loadLabelByCondition(selectedItem: String, value: String): MutableList { + val property = when (selectedItem) { + LocaleConstant.SPINNER_ARRAY[0] -> LabelBeanDao.Properties.IdentifierId + LocaleConstant.SPINNER_ARRAY[1] -> LabelBeanDao.Properties.Area + LocaleConstant.SPINNER_ARRAY[2] -> LabelBeanDao.Properties.Line + LocaleConstant.SPINNER_ARRAY[3] -> LabelBeanDao.Properties.Road + LocaleConstant.SPINNER_ARRAY[4] -> LabelBeanDao.Properties.Owner + LocaleConstant.SPINNER_ARRAY[5] -> LabelBeanDao.Properties.Person + LocaleConstant.SPINNER_ARRAY[6] -> LabelBeanDao.Properties.InstallTime + else -> LabelBeanDao.Properties.Remark + } + return labelBeanDao.queryBuilder().where(property.eq(value)).list() + } + fun queryLabelById(identifierId: String): List { return labelBeanDao.queryBuilder() .where(LabelBeanDao.Properties.IdentifierId.eq(identifierId)) diff --git a/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt b/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt index b5aad2a..9fb1c87 100644 --- a/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt @@ -28,4 +28,5 @@ val POPUP_TITLES = arrayOf("更新数据", "下载工单", "关于软件", "事件上报", "标识器补全") var POINT_TYPE_ARRAY = arrayOf("", "管线", "管线附属物", "管线特征管点", "交叉穿越点") + var SPINNER_ARRAY = arrayOf("标识器ID", "所属区域", "所属线路", "所属道路", "权属单位", "安装部门", "安装时间", "备注") } \ 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 ba704e3..107deb7 100644 --- a/app/src/main/java/com/casic/detector/view/MainActivity.kt +++ b/app/src/main/java/com/casic/detector/view/MainActivity.kt @@ -36,6 +36,7 @@ import com.casic.detector.utils.* import com.casic.detector.vm.TaskViewModel import com.casic.detector.vm.VersionViewModel +import com.casic.detector.widgets.QueryMarkerDialog import com.casic.detector.widgets.SamplePopupWindow import com.gyf.immersionbar.ImmersionBar import com.pengxh.kt.lite.callback.OnDownloadListener @@ -65,9 +66,11 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val progressDialog by lazy { ProgressDialog(this) } private var labelBeans = ArrayList() - private lateinit var clusterOverlay: ClusterOverlay + private var clusterOverlay: ClusterOverlay? = null private val backDrawables = HashMap() private val regionRadius by lazy { LocaleConstant.RADIUS_SIZE.dp2px(this) } + private var latitude: Double = 0.0 + private var longitude: Double = 0.0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -96,8 +99,8 @@ aMap.myLocationStyle = locationStyle//设置定位蓝点的Style aMap.isMyLocationEnabled = true//设置是否显示定位小蓝点 aMap.setOnMyLocationChangeListener { - val longitude = it.longitude - val latitude = it.latitude + longitude = it.longitude + latitude = it.latitude //经纬度逆编码 LocationHub.antiCodingLocation(context, it) { address -> currentLocationView.text = address @@ -118,6 +121,16 @@ } } }) + + aMap.setOnMapLongClickListener { + //协程异步显示默认数据 + CoroutineScope(Dispatchers.Main).launch { + labelBeans = withContext(Dispatchers.IO) { + DataBaseManager.get.loadTaskLabels() as ArrayList + } + showLabelsOnMap() + } + } } private fun initData() { @@ -240,6 +253,7 @@ } private fun showLabelsOnMap() { + clusterOverlay?.onDestroy() val clusterItems = ArrayList() labelBeans.forEach { val latLng = LatLng(it.lat.toDouble(), it.lng.toDouble(), false) @@ -248,7 +262,7 @@ } clusterOverlay = ClusterOverlay(context, aMap, clusterItems, regionRadius) - clusterOverlay.setClusterRender { clusterNum -> + clusterOverlay?.setClusterRender { clusterNum -> val radius = 80f.dp2px(context) if (clusterNum == 1) { var bitmapDrawable: Drawable? = backDrawables[1] @@ -286,7 +300,7 @@ bitmapDrawable } } - clusterOverlay.setOnClusterClickListener { _, items -> + clusterOverlay?.setOnClusterClickListener { _, items -> var item: RegionItem? = null val builder = LatLngBounds.Builder() for (clusterItem in items) { @@ -354,7 +368,31 @@ //查看 viewButton.setOnClickListener { + QueryMarkerDialog.Builder() + .setContext(context) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setHintMessage("请输入查询条件") + .setNegativeButton("取消") + .setPositiveButton("确定") + .setOnDialogButtonClickListener(object : + QueryMarkerDialog.OnDialogButtonClickListener { + override fun onConfirmClick(selectedItem: String, value: String) { + //查询数据库 + CoroutineScope(Dispatchers.Main).launch { + labelBeans = withContext(Dispatchers.IO) { + DataBaseManager.get.loadLabelByCondition( + selectedItem, value + ) as ArrayList + } + showLabelsOnMap() + } + } + override fun onCancelClick() { + + } + }).build().show() } //巡检 @@ -425,11 +463,15 @@ //TODO //事件上报 private fun uploadEvent() { -// if(){ + if (latitude != 0.0 && longitude != 0.0) { +// if () { // -// }else{ +// } else { // -// } +// } + } else { + "定位中,请稍后再试...".show(this) + } } //标识器补全 diff --git a/app/build.gradle b/app/build.gradle index b9e1ce2..b3cd0c8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ defaultConfig { applicationId "com.casic.detector" - minSdkVersion 23 + minSdkVersion 22 targetSdkVersion 32 versionCode 1 versionName "1.0.0.0" @@ -44,7 +44,7 @@ applicationVariants.all { variant -> variant.outputs.all { - outputFileName = "TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" + outputFileName = "COM_TCY" + getBuildDate() + "_" + defaultConfig.versionName + ".apk" } } diff --git a/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt b/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt index 271e9a1..581b66c 100644 --- a/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt +++ b/app/src/main/java/com/casic/detector/utils/DataBaseManager.kt @@ -29,6 +29,20 @@ return labelBeanDao.loadAll() } + fun loadLabelByCondition(selectedItem: String, value: String): MutableList { + val property = when (selectedItem) { + LocaleConstant.SPINNER_ARRAY[0] -> LabelBeanDao.Properties.IdentifierId + LocaleConstant.SPINNER_ARRAY[1] -> LabelBeanDao.Properties.Area + LocaleConstant.SPINNER_ARRAY[2] -> LabelBeanDao.Properties.Line + LocaleConstant.SPINNER_ARRAY[3] -> LabelBeanDao.Properties.Road + LocaleConstant.SPINNER_ARRAY[4] -> LabelBeanDao.Properties.Owner + LocaleConstant.SPINNER_ARRAY[5] -> LabelBeanDao.Properties.Person + LocaleConstant.SPINNER_ARRAY[6] -> LabelBeanDao.Properties.InstallTime + else -> LabelBeanDao.Properties.Remark + } + return labelBeanDao.queryBuilder().where(property.eq(value)).list() + } + fun queryLabelById(identifierId: String): List { return labelBeanDao.queryBuilder() .where(LabelBeanDao.Properties.IdentifierId.eq(identifierId)) diff --git a/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt b/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt index b5aad2a..9fb1c87 100644 --- a/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt +++ b/app/src/main/java/com/casic/detector/utils/LocaleConstant.kt @@ -28,4 +28,5 @@ val POPUP_TITLES = arrayOf("更新数据", "下载工单", "关于软件", "事件上报", "标识器补全") var POINT_TYPE_ARRAY = arrayOf("", "管线", "管线附属物", "管线特征管点", "交叉穿越点") + var SPINNER_ARRAY = arrayOf("标识器ID", "所属区域", "所属线路", "所属道路", "权属单位", "安装部门", "安装时间", "备注") } \ 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 ba704e3..107deb7 100644 --- a/app/src/main/java/com/casic/detector/view/MainActivity.kt +++ b/app/src/main/java/com/casic/detector/view/MainActivity.kt @@ -36,6 +36,7 @@ import com.casic.detector.utils.* import com.casic.detector.vm.TaskViewModel import com.casic.detector.vm.VersionViewModel +import com.casic.detector.widgets.QueryMarkerDialog import com.casic.detector.widgets.SamplePopupWindow import com.gyf.immersionbar.ImmersionBar import com.pengxh.kt.lite.callback.OnDownloadListener @@ -65,9 +66,11 @@ private val samplePopupWindow by lazy { SamplePopupWindow(this) } private val progressDialog by lazy { ProgressDialog(this) } private var labelBeans = ArrayList() - private lateinit var clusterOverlay: ClusterOverlay + private var clusterOverlay: ClusterOverlay? = null private val backDrawables = HashMap() private val regionRadius by lazy { LocaleConstant.RADIUS_SIZE.dp2px(this) } + private var latitude: Double = 0.0 + private var longitude: Double = 0.0 override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -96,8 +99,8 @@ aMap.myLocationStyle = locationStyle//设置定位蓝点的Style aMap.isMyLocationEnabled = true//设置是否显示定位小蓝点 aMap.setOnMyLocationChangeListener { - val longitude = it.longitude - val latitude = it.latitude + longitude = it.longitude + latitude = it.latitude //经纬度逆编码 LocationHub.antiCodingLocation(context, it) { address -> currentLocationView.text = address @@ -118,6 +121,16 @@ } } }) + + aMap.setOnMapLongClickListener { + //协程异步显示默认数据 + CoroutineScope(Dispatchers.Main).launch { + labelBeans = withContext(Dispatchers.IO) { + DataBaseManager.get.loadTaskLabels() as ArrayList + } + showLabelsOnMap() + } + } } private fun initData() { @@ -240,6 +253,7 @@ } private fun showLabelsOnMap() { + clusterOverlay?.onDestroy() val clusterItems = ArrayList() labelBeans.forEach { val latLng = LatLng(it.lat.toDouble(), it.lng.toDouble(), false) @@ -248,7 +262,7 @@ } clusterOverlay = ClusterOverlay(context, aMap, clusterItems, regionRadius) - clusterOverlay.setClusterRender { clusterNum -> + clusterOverlay?.setClusterRender { clusterNum -> val radius = 80f.dp2px(context) if (clusterNum == 1) { var bitmapDrawable: Drawable? = backDrawables[1] @@ -286,7 +300,7 @@ bitmapDrawable } } - clusterOverlay.setOnClusterClickListener { _, items -> + clusterOverlay?.setOnClusterClickListener { _, items -> var item: RegionItem? = null val builder = LatLngBounds.Builder() for (clusterItem in items) { @@ -354,7 +368,31 @@ //查看 viewButton.setOnClickListener { + QueryMarkerDialog.Builder() + .setContext(context) + .setTitle("查看标识器") + .setSpinnerArray(LocaleConstant.SPINNER_ARRAY) + .setHintMessage("请输入查询条件") + .setNegativeButton("取消") + .setPositiveButton("确定") + .setOnDialogButtonClickListener(object : + QueryMarkerDialog.OnDialogButtonClickListener { + override fun onConfirmClick(selectedItem: String, value: String) { + //查询数据库 + CoroutineScope(Dispatchers.Main).launch { + labelBeans = withContext(Dispatchers.IO) { + DataBaseManager.get.loadLabelByCondition( + selectedItem, value + ) as ArrayList + } + showLabelsOnMap() + } + } + override fun onCancelClick() { + + } + }).build().show() } //巡检 @@ -425,11 +463,15 @@ //TODO //事件上报 private fun uploadEvent() { -// if(){ + if (latitude != 0.0 && longitude != 0.0) { +// if () { // -// }else{ +// } else { // -// } +// } + } else { + "定位中,请稍后再试...".show(this) + } } //标识器补全 diff --git a/app/src/main/java/com/casic/detector/widgets/QueryMarkerDialog.kt b/app/src/main/java/com/casic/detector/widgets/QueryMarkerDialog.kt new file mode 100644 index 0000000..f453bc1 --- /dev/null +++ b/app/src/main/java/com/casic/detector/widgets/QueryMarkerDialog.kt @@ -0,0 +1,142 @@ +package com.casic.detector.widgets + +import android.app.Dialog +import android.content.Context +import android.os.Bundle +import android.view.View +import android.widget.* +import com.casic.detector.R +import com.pengxh.kt.lite.extensions.initDialogLayoutParams +import com.pengxh.kt.lite.extensions.show +import com.pengxh.kt.lite.widget.DeleteEditText + +class QueryMarkerDialog private constructor(builder: Builder) : Dialog( + builder.context, R.style.UserDefinedDialogStyle +) { + private val ctx = builder.context + private val title = builder.title + private val spinnerArray = builder.spinnerArray + private val hint = builder.hint + private val positiveBtn = builder.positiveBtn + private val negativeBtn = builder.negativeBtn + private val listener = builder.listener + + class Builder { + lateinit var context: Context + lateinit var title: String + lateinit var spinnerArray: Array + lateinit var hint: String + lateinit var positiveBtn: String + lateinit var negativeBtn: String + lateinit var listener: OnDialogButtonClickListener + + fun setContext(context: Context): Builder { + this.context = context + return this + } + + fun setTitle(title: String): Builder { + this.title = title + return this + } + + fun setSpinnerArray(spinnerArray: Array): Builder { + this.spinnerArray = spinnerArray + return this + } + + fun setHintMessage(hint: String): Builder { + this.hint = hint + return this + } + + fun setPositiveButton(name: String): Builder { + positiveBtn = name + return this + } + + fun setNegativeButton(name: String): Builder { + negativeBtn = name + return this + } + + fun setOnDialogButtonClickListener(listener: OnDialogButtonClickListener): Builder { + this.listener = listener + return this + } + + fun build(): QueryMarkerDialog { + return QueryMarkerDialog(this) + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + this.initDialogLayoutParams(0.8f) + setContentView(R.layout.dialog_query_marker) + setCanceledOnTouchOutside(false) + initView() + } + + private var selectedItem = "" + + private fun initView() { + val dialogTitleView: TextView = findViewById(R.id.dialogTitleView) + val dialogSpinnerView: Spinner = findViewById(R.id.dialogSpinnerView) + val dialogInputView: DeleteEditText = findViewById(R.id.dialogInputView) + val dialogCancelButton = findViewById