|
@@ -1,5 +1,6 @@
|
|
|
package com.grkj.iscs.view.fragment
|
|
package com.grkj.iscs.view.fragment
|
|
|
|
|
|
|
|
|
|
+import android.graphics.PointF
|
|
|
import android.view.View
|
|
import android.view.View
|
|
|
import android.widget.ImageView
|
|
import android.widget.ImageView
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
import androidx.constraintlayout.widget.ConstraintLayout
|
|
@@ -12,11 +13,15 @@ import com.grkj.iscs.model.bo.PageChangeBO
|
|
|
import com.grkj.iscs.model.vo.machinery.MachineryDetailRespVO
|
|
import com.grkj.iscs.model.vo.machinery.MachineryDetailRespVO
|
|
|
import com.grkj.iscs.model.vo.ticket.LotoMapRespVO
|
|
import com.grkj.iscs.model.vo.ticket.LotoMapRespVO
|
|
|
import com.grkj.iscs.model.vo.ticket.StepDetailRespVO
|
|
import com.grkj.iscs.model.vo.ticket.StepDetailRespVO
|
|
|
|
|
+import com.grkj.iscs.util.CommonUtils
|
|
|
|
|
+import com.grkj.iscs.util.ToastUtils
|
|
|
import com.grkj.iscs.util.log.LogUtil
|
|
import com.grkj.iscs.util.log.LogUtil
|
|
|
import com.grkj.iscs.view.base.BaseMvpFragment
|
|
import com.grkj.iscs.view.base.BaseMvpFragment
|
|
|
import com.grkj.iscs.view.dialog.TipDialog
|
|
import com.grkj.iscs.view.dialog.TipDialog
|
|
|
import com.grkj.iscs.view.iview.IStepView
|
|
import com.grkj.iscs.view.iview.IStepView
|
|
|
import com.grkj.iscs.view.presenter.StepPresenter
|
|
import com.grkj.iscs.view.presenter.StepPresenter
|
|
|
|
|
+import com.grkj.iscs.view.widget.CustomStationLayer
|
|
|
|
|
+import com.onlylemi.mapview.library.MapViewListener
|
|
|
import com.zhy.adapter.recyclerview.CommonAdapter
|
|
import com.zhy.adapter.recyclerview.CommonAdapter
|
|
|
import com.zhy.adapter.recyclerview.base.ViewHolder
|
|
import com.zhy.adapter.recyclerview.base.ViewHolder
|
|
|
import kotlin.math.ceil
|
|
import kotlin.math.ceil
|
|
@@ -34,6 +39,9 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
private var mMachineryDetail: MachineryDetailRespVO? = null
|
|
private var mMachineryDetail: MachineryDetailRespVO? = null
|
|
|
private var mStep: Int = 0
|
|
private var mStep: Int = 0
|
|
|
private lateinit var mTipDialog: TipDialog
|
|
private lateinit var mTipDialog: TipDialog
|
|
|
|
|
+ private var stationLayer: CustomStationLayer? = null
|
|
|
|
|
+ private val mStationList = mutableListOf<CustomStationLayer.IsolationPoint>()
|
|
|
|
|
+ private var mMapPicWidth = 1
|
|
|
|
|
|
|
|
override val viewBinding: FragmentStepBinding
|
|
override val viewBinding: FragmentStepBinding
|
|
|
get() = FragmentStepBinding.inflate(layoutInflater)
|
|
get() = FragmentStepBinding.inflate(layoutInflater)
|
|
@@ -83,7 +91,7 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
mBinding?.rvLoto?.adapter = object : CommonAdapter<LotoMapRespVO>(requireContext(), R.layout.item_rv_loto, mLotoList) {
|
|
mBinding?.rvLoto?.adapter = object : CommonAdapter<LotoMapRespVO>(requireContext(), R.layout.item_rv_loto, mLotoList) {
|
|
|
override fun convert(holder: ViewHolder, loto: LotoMapRespVO, position: Int) {
|
|
override fun convert(holder: ViewHolder, loto: LotoMapRespVO, position: Int) {
|
|
|
val cl = holder.getView<ConstraintLayout>(R.id.cl_container)
|
|
val cl = holder.getView<ConstraintLayout>(R.id.cl_container)
|
|
@@ -127,6 +135,32 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
mChangePage?.machineryId, mChangePage?.machineryName))
|
|
mChangePage?.machineryId, mChangePage?.machineryName))
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ initMap()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private fun initMap() {
|
|
|
|
|
+ mBinding?.mapview?.isScaleAndRotateTogether = false
|
|
|
|
|
+ mBinding?.mapview?.setMapViewListener(object : MapViewListener {
|
|
|
|
|
+ override fun onMapLoadSuccess() {
|
|
|
|
|
+ if (stationLayer != null) {
|
|
|
|
|
+ mBinding?.mapview?.currentRotateDegrees = 0f
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ stationLayer = CustomStationLayer(mBinding?.mapview, mStationList)
|
|
|
|
|
+ stationLayer?.setMarkIsClickListener(object : CustomStationLayer.MarkIsClickListener {
|
|
|
|
|
+ override fun markIsClick(index: Int, btnIndex: Int) {
|
|
|
|
|
+// ToastUtils.tip(mPointList[index].name + " is selected, btnIndex is " + btnIndex)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ mBinding?.mapview?.addLayer(stationLayer)
|
|
|
|
|
+ mBinding?.mapview?.refresh()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onMapLoadFail() {
|
|
|
|
|
+ ToastUtils.tip("onMapLoadFail")
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun refreshPage(pageChangeBO: PageChangeBO) {
|
|
override fun refreshPage(pageChangeBO: PageChangeBO) {
|
|
@@ -172,6 +206,42 @@ class StepFragment(val goBack: () -> Unit, val changePage: (PageChangeBO) -> Uni
|
|
|
(mBinding?.rvLoto?.layoutManager as GridLayoutManager).spanCount = spanCount
|
|
(mBinding?.rvLoto?.layoutManager as GridLayoutManager).spanCount = spanCount
|
|
|
|
|
|
|
|
mBinding?.rvLoto?.adapter?.notifyDataSetChanged()
|
|
mBinding?.rvLoto?.adapter?.notifyDataSetChanged()
|
|
|
|
|
+
|
|
|
|
|
+ if (mLotoList.isNotEmpty()) {
|
|
|
|
|
+ mLotoList[0].mapId?.let { itId ->
|
|
|
|
|
+ presenter?.getMapInfo(itId) { itMapInfo ->
|
|
|
|
|
+ itMapInfo?.imageUrl ?: return@getMapInfo
|
|
|
|
|
+ CommonUtils.loadBitmapFromUrl(requireContext(), itMapInfo.imageUrl) {
|
|
|
|
|
+ if (it == null) {
|
|
|
|
|
+ LogUtil.e("Map pic is null")
|
|
|
|
|
+ return@loadBitmapFromUrl
|
|
|
|
|
+ }
|
|
|
|
|
+ mMapPicWidth = it.width
|
|
|
|
|
+
|
|
|
|
|
+ mStationList.clear()
|
|
|
|
|
+
|
|
|
|
|
+ val location = IntArray(2)
|
|
|
|
|
+ mBinding?.mapview?.getLocationOnScreen(location)
|
|
|
|
|
+
|
|
|
|
|
+ itMapInfo.pointList?.forEach { itPoint ->
|
|
|
|
|
+ val locationX = (itPoint.x!!.toFloat() - (itMapInfo.x!!.toFloat() / 50)) * 50 / itMapInfo.width!!.toFloat() * it.width
|
|
|
|
|
+ val locationY = (itPoint.y!!.toFloat() + 1 - itMapInfo.y!!.toFloat() / 50) * 50 / itMapInfo.height!!.toFloat() * it.height
|
|
|
|
|
+
|
|
|
|
|
+ mStationList.add(
|
|
|
|
|
+ CustomStationLayer.IsolationPoint(
|
|
|
|
|
+ PointF(locationX, locationY),
|
|
|
|
|
+ itPoint.entityName!!,
|
|
|
|
|
+ itPoint.entityId!!,
|
|
|
|
|
+ mLotoList.any { it.entityId == itPoint.entityId }
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ mBinding?.mapview?.loadMap(it)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|