diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_casic.png b/app/src/main/res/mipmap-xxxhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_casic.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_casic.png b/app/src/main/res/mipmap-xxxhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/popup.png b/app/src/main/res/mipmap-xxxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/popup.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_casic.png b/app/src/main/res/mipmap-xxxhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/popup.png b/app/src/main/res/mipmap-xxxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_background.png b/app/src/main/res/mipmap-xxxhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_background.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_casic.png b/app/src/main/res/mipmap-xxxhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/popup.png b/app/src/main/res/mipmap-xxxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_background.png b/app/src/main/res/mipmap-xxxhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_casic.png b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_casic.png b/app/src/main/res/mipmap-xxxhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/popup.png b/app/src/main/res/mipmap-xxxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_background.png b/app/src/main/res/mipmap-xxxhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_casic.png b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_logo.png b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_casic.png b/app/src/main/res/mipmap-xxxhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/popup.png b/app/src/main/res/mipmap-xxxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_background.png b/app/src/main/res/mipmap-xxxhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_casic.png b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_logo.png b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_text.png b/app/src/main/res/mipmap-xxxhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_text.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_casic.png b/app/src/main/res/mipmap-xxxhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/popup.png b/app/src/main/res/mipmap-xxxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_background.png b/app/src/main/res/mipmap-xxxhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_casic.png b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_logo.png b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_text.png b/app/src/main/res/mipmap-xxxhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/well_location.png b/app/src/main/res/mipmap-xxxhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/well_location.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_casic.png b/app/src/main/res/mipmap-xxxhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/popup.png b/app/src/main/res/mipmap-xxxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_background.png b/app/src/main/res/mipmap-xxxhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_casic.png b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_logo.png b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_text.png b/app/src/main/res/mipmap-xxxhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/well_location.png b/app/src/main/res/mipmap-xxxhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ybf.png b/app/src/main/res/mipmap-xxxhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ybf.png Binary files differ diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt index 6abb9c1..7c11b75 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/HomePageNoClusterFragment.kt @@ -50,7 +50,7 @@ * */ class HomePageNoClusterFragment : KotlinBaseFragment(), AMap.OnCameraChangeListener, AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, - AMap.OnInfoWindowClickListener { + AMap.OnInfoWindowClickListener, AMap.OnMapClickListener { private val kTag = "NoClusterFragment" private val easyPopupWindow by lazy { EasyPopupWindow(requireContext()) } @@ -58,11 +58,12 @@ private lateinit var orderViewModel: OrderViewModel private lateinit var lineViewModel: PipelineViewModel private lateinit var aMap: AMap + private var clickedMarker: Marker? = null /** * 自定义Marker弹出框 * */ - private lateinit var v: View + private var infoWindow: View? = null /** * 所有窨井列表信息集合 @@ -232,6 +233,8 @@ aMap.setInfoWindowAdapter(this) //信息窗点击事件 aMap.addOnInfoWindowClickListener(this) + //地图点击事件,用于隐藏infoWindow + aMap.setOnMapClickListener(this) } override fun initEvent() { @@ -277,24 +280,48 @@ } override fun onMarkerClick(marker: Marker?): Boolean { - v = LayoutInflater.from(requireContext()).inflate(R.layout.popup_map_info, null) - - //显示闸井信息 - marker?.showInfoWindow() + marker?.apply { + clickedMarker = this + if (isInfoWindowShown) { + hideInfoWindow() + } else { + showInfoWindow() + } + } return true } - override fun getInfoWindow(marker: Marker?): View { + override fun onMapClick(p0: LatLng?) { + clickedMarker?.apply { + if (isInfoWindowShown) { + hideInfoWindow() + } + } + } + + override fun getInfoWindow(marker: Marker?): View? { + if (infoWindow == null) { + infoWindow = LayoutInflater.from(requireContext()).inflate( + R.layout.popup_map_info, null + ) + } + marker?.apply { + renderWindow(this, infoWindow!!) + } + return infoWindow + } + + private fun renderWindow(marker: Marker, view: View) { //反射得到popup里面的控件对象 - val wellNameView = v.findViewById(R.id.wellNameView) - val wellCodeView = v.findViewById(R.id.wellCodeView) - val wellTypeView = v.findViewById(R.id.wellTypeView) - val wellStateView = v.findViewById(R.id.wellStateView) - val deepView = v.findViewById(R.id.deepView) - val locationView = v.findViewById(R.id.locationView) + val wellNameView = view.findViewById(R.id.wellNameView) + val wellCodeView = view.findViewById(R.id.wellCodeView) + val wellTypeView = view.findViewById(R.id.wellTypeView) + val wellStateView = view.findViewById(R.id.wellStateView) + val deepView = view.findViewById(R.id.deepView) + val locationView = view.findViewById(R.id.locationView) //绑定数据 - val clicked = marker?.position!! + val clicked = marker.position wellModels.forEach { well -> if (clicked.latitude == well.latGaode!!.toDouble() && clicked.longitude == well.lngGaode!!.toDouble()) { wellNameView.text = String.format("点位名称: ${well.wellName}") @@ -310,7 +337,6 @@ locationView.text = String.format("详细位置: ${well.position}") } } - return v } /** @@ -337,7 +363,7 @@ } override fun onCancelClick() { - remove() + hideInfoWindow() } }).build().show() } diff --git a/app/src/main/res/mipmap-hdpi/clock.png b/app/src/main/res/mipmap-hdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/load_image_error.png b/app/src/main/res/mipmap-hdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_bottom.png b/app/src/main/res/mipmap-hdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/login_casic.png b/app/src/main/res/mipmap-hdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_background.png b/app/src/main/res/mipmap-hdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_casic.png b/app/src/main/res/mipmap-hdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_logo.png b/app/src/main/res/mipmap-hdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/splash_text.png b/app/src/main/res/mipmap-hdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/well_location.png b/app/src/main/res/mipmap-hdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ybf.png b/app/src/main/res/mipmap-hdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-hdpi/ycf.png b/app/src/main/res/mipmap-hdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/clock.png b/app/src/main/res/mipmap-mdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/load_image_error.png b/app/src/main/res/mipmap-mdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_bottom.png b/app/src/main/res/mipmap-mdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/login_casic.png b/app/src/main/res/mipmap-mdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/popup.png b/app/src/main/res/mipmap-mdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_background.png b/app/src/main/res/mipmap-mdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_casic.png b/app/src/main/res/mipmap-mdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_logo.png b/app/src/main/res/mipmap-mdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/splash_text.png b/app/src/main/res/mipmap-mdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/well_location.png b/app/src/main/res/mipmap-mdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ybf.png b/app/src/main/res/mipmap-mdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-mdpi/ycf.png b/app/src/main/res/mipmap-mdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/clock.png b/app/src/main/res/mipmap-xhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/load_image_error.png b/app/src/main/res/mipmap-xhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_bottom.png b/app/src/main/res/mipmap-xhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/login_casic.png b/app/src/main/res/mipmap-xhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/popup.png b/app/src/main/res/mipmap-xhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_background.png b/app/src/main/res/mipmap-xhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_casic.png b/app/src/main/res/mipmap-xhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_logo.png b/app/src/main/res/mipmap-xhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/splash_text.png b/app/src/main/res/mipmap-xhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/well_location.png b/app/src/main/res/mipmap-xhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ybf.png b/app/src/main/res/mipmap-xhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/ycf.png b/app/src/main/res/mipmap-xhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ycf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxhdpi/popup.png b/app/src/main/res/mipmap-xxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/clock.png b/app/src/main/res/mipmap-xxxhdpi/clock.png new file mode 100644 index 0000000..5359c6f --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/clock.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/load_image_error.png b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png new file mode 100644 index 0000000..357cbde --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/load_image_error.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_bottom.png b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png new file mode 100644 index 0000000..6a4f010 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_bottom.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/login_casic.png b/app/src/main/res/mipmap-xxxhdpi/login_casic.png new file mode 100644 index 0000000..edbe69a --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/login_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/popup.png b/app/src/main/res/mipmap-xxxhdpi/popup.png new file mode 100644 index 0000000..0275003 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/popup.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_background.png b/app/src/main/res/mipmap-xxxhdpi/splash_background.png new file mode 100644 index 0000000..3fcca9d --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_background.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_casic.png b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png new file mode 100644 index 0000000..37c7e47 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_casic.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_logo.png b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png new file mode 100644 index 0000000..ac2ba0c --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_logo.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/splash_text.png b/app/src/main/res/mipmap-xxxhdpi/splash_text.png new file mode 100644 index 0000000..25684d7 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/splash_text.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/well_location.png b/app/src/main/res/mipmap-xxxhdpi/well_location.png new file mode 100644 index 0000000..b89a974 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/well_location.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ybf.png b/app/src/main/res/mipmap-xxxhdpi/ybf.png new file mode 100644 index 0000000..f1754d2 --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ybf.png Binary files differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ycf.png b/app/src/main/res/mipmap-xxxhdpi/ycf.png new file mode 100644 index 0000000..728f8cf --- /dev/null +++ b/app/src/main/res/mipmap-xxxhdpi/ycf.png Binary files differ