This commit is contained in:
qiji4215 2023-07-21 15:40:32 +08:00
commit 7df7cf1345
25 changed files with 1096 additions and 751 deletions

View File

@ -133,6 +133,8 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1' annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1'
// implementation "io.realm:realm-kotlin-extensions:6.1.0" // implementation "io.realm:realm-kotlin-extensions:6.1.0"
//
implementation 'com.yanzhenjie.recyclerview:x:1.3.2'
} }
// //
kapt { kapt {

View File

@ -3,6 +3,7 @@ package com.navinfo.omqs.db
import android.os.Build import android.os.Build
import android.util.Log import android.util.Log
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.collect.library.data.entity.RenderEntity import com.navinfo.collect.library.data.entity.RenderEntity
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
import com.navinfo.collect.library.map.NIMapController import com.navinfo.collect.library.map.NIMapController
@ -85,6 +86,39 @@ class RealmOperateHelper() {
} }
suspend fun captureTaskLink(
taskId: Int,
point: GeoPoint,
buffer: Double = DEFAULT_BUFFER,
bufferType: BUFFER_TYPE = DEFAULT_BUFFER_TYPE,
): HadLinkDvoBean? {
val polygon = getPolygonFromPoint(
GeometryTools.createPoint(point.longitude, point.latitude),
buffer,
bufferType
)
val realm = Realm.getDefaultInstance()
val realmList = realm.where(HadLinkDvoBean::class.java)
.equalTo("taskId", taskId)
.findAll()
var linkBean: HadLinkDvoBean? = null
var nearLast: Double = 99999.99
for (link in realmList) {
if (polygon.intersects(GeometryTools.createGeometry(link.geometry))) {
val near = point.distance(GeometryTools.createGeoPoint(link.geometry))
if (near < nearLast) {
nearLast = near
linkBean = link
}
}
}
if (linkBean != null)
return realm.copyFromRealm(linkBean)
return null
}
suspend fun queryLink(linkPid: String): RenderEntity? { suspend fun queryLink(linkPid: String): RenderEntity? {
var link: RenderEntity? = null var link: RenderEntity? = null
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
@ -237,6 +271,8 @@ class RealmOperateHelper() {
Log.d("queryLink", wkt.toString()) Log.d("queryLink", wkt.toString())
return wkt return wkt
} }
} }
enum class BUFFER_TYPE(val index: Int) { enum class BUFFER_TYPE(val index: Int) {

View File

@ -163,7 +163,8 @@ class TaskUploadScope(
var s: String = "%.3f".format(hadLinkDvoBean.length)//保留一位小数(且支持四舍五入) var s: String = "%.3f".format(hadLinkDvoBean.length)//保留一位小数(且支持四舍五入)
val objects = realm.where(QsRecordBean::class.java) val objects = realm.where(QsRecordBean::class.java)
.equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).findAll() .equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).and()
.equalTo("taskId", hadLinkDvoBean.taskId).findAll()
if (objects != null && objects.size > 0) { if (objects != null && objects.size > 0) {
val copyList = realm.copyFromRealm(objects) val copyList = realm.copyFromRealm(objects)
@ -183,7 +184,7 @@ class TaskUploadScope(
var dataLevel = 0 var dataLevel = 0
if(hadLinkDvoBean.linkInfo!=null){ if (hadLinkDvoBean.linkInfo != null) {
roadClassfcation = hadLinkDvoBean.linkInfo!!.kind roadClassfcation = hadLinkDvoBean.linkInfo!!.kind
roadFunctionGrade = hadLinkDvoBean.linkInfo!!.functionLevel roadFunctionGrade = hadLinkDvoBean.linkInfo!!.functionLevel
dataLevel = hadLinkDvoBean.linkInfo!!.dataLevel dataLevel = hadLinkDvoBean.linkInfo!!.dataLevel

View File

@ -12,7 +12,6 @@ import android.widget.EditText
import android.widget.Toast import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.annotation.RequiresApi
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -20,7 +19,6 @@ import androidx.navigation.findNavController
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.navinfo.collect.library.data.entity.NiLocation
import com.navinfo.collect.library.map.NIMapController import com.navinfo.collect.library.map.NIMapController
import com.navinfo.omqs.Constant import com.navinfo.omqs.Constant
import com.navinfo.omqs.R import com.navinfo.omqs.R
@ -43,7 +41,6 @@ import com.navinfo.omqs.util.SpeakMode
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.oscim.core.GeoPoint import org.oscim.core.GeoPoint
import org.oscim.layers.marker.MarkerItem
import org.oscim.renderer.GLViewport import org.oscim.renderer.GLViewport
import org.videolan.vlc.Util import org.videolan.vlc.Util
import java.math.BigDecimal import java.math.BigDecimal
@ -110,7 +107,6 @@ class MainActivity : BaseActivity() {
} }
//点击详细信息 //点击详细信息
@RequiresApi(Build.VERSION_CODES.N)
override fun onMoreInfoClick(selectTag: String, tag: String, signBean: SignBean) { override fun onMoreInfoClick(selectTag: String, tag: String, signBean: SignBean) {
viewModel.showSignMoreInfo(signBean.renderEntity) viewModel.showSignMoreInfo(signBean.renderEntity)
val fragment = val fragment =
@ -151,7 +147,6 @@ class MainActivity : BaseActivity() {
} }
@RequiresApi(Build.VERSION_CODES.N)
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -231,8 +226,7 @@ class MainActivity : BaseActivity() {
val bundle = Bundle() val bundle = Bundle()
bundle.putString("TaskLinkId", it) bundle.putString("TaskLinkId", it)
findNavController(R.id.main_activity_right_fragment).navigate( findNavController(R.id.main_activity_right_fragment).navigate(
R.id.TaskLinkFragment, R.id.TaskLinkFragment, bundle
bundle
) )
} }
@ -410,7 +404,7 @@ class MainActivity : BaseActivity() {
val inputDialog = MaterialAlertDialogBuilder( val inputDialog = MaterialAlertDialogBuilder(
this this
).setTitle("坐标定位").setView(view) ).setTitle("坐标定位").setView(view)
var editText = view.findViewById<EditText>(R.id.dialog_edittext) val editText = view.findViewById<EditText>(R.id.dialog_edittext)
editText.hint = "请输入经纬度例如:\n116.1234567,39.1234567\n116.1234567 39.1234567" editText.hint = "请输入经纬度例如:\n116.1234567,39.1234567\n116.1234567 39.1234567"
inputDialog.setNegativeButton("取消") { dialog, _ -> inputDialog.setNegativeButton("取消") { dialog, _ ->
dialog.dismiss() dialog.dismiss()
@ -449,7 +443,6 @@ class MainActivity : BaseActivity() {
mapController.mMapView.onPause() mapController.mMapView.onPause()
} }
@RequiresApi(Build.VERSION_CODES.N)
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
viewModel.speakMode?.shutdown() viewModel.speakMode?.shutdown()
@ -480,7 +473,6 @@ class MainActivity : BaseActivity() {
/** /**
* 打开相机预览 * 打开相机预览
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun openCamera() { fun openCamera() {
//显示轨迹图层 //显示轨迹图层
viewModel.onClickCameraButton(this) viewModel.onClickCameraButton(this)
@ -489,7 +481,6 @@ class MainActivity : BaseActivity() {
/** /**
* 开关菜单 * 开关菜单
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun onClickMenu() { fun onClickMenu() {
//显示菜单图层 //显示菜单图层
viewModel.onClickMenu() viewModel.onClickMenu()
@ -597,7 +588,6 @@ class MainActivity : BaseActivity() {
/** /**
* 点击线选择 * 点击线选择
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun selectLineOnclick() { fun selectLineOnclick() {
viewModel.setSelectRoad(!viewModel.isSelectRoad()) viewModel.setSelectRoad(!viewModel.isSelectRoad())
binding.mainActivitySelectLine.isSelected = viewModel.isSelectRoad() binding.mainActivitySelectLine.isSelected = viewModel.isSelectRoad()
@ -606,7 +596,6 @@ class MainActivity : BaseActivity() {
/** /**
* 点击线选择 * 点击线选择
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun tracePointsOnclick() { fun tracePointsOnclick() {
viewModel.setSelectTrace(!viewModel.isSelectTrace()) viewModel.setSelectTrace(!viewModel.isSelectTrace())
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace() binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
@ -622,7 +611,6 @@ class MainActivity : BaseActivity() {
/** /**
* 点击结束轨迹操作 * 点击结束轨迹操作
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun finishTraceOnclick() { fun finishTraceOnclick() {
setIndoorGroupEnable(false) setIndoorGroupEnable(false)
viewModel.setSelectTrace(false) viewModel.setSelectTrace(false)
@ -637,7 +625,6 @@ class MainActivity : BaseActivity() {
/** /**
* 点击结束轨迹操作 * 点击结束轨迹操作
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun mediaFlagOnclick() { fun mediaFlagOnclick() {
/* viewModel.setMediaFlag(!viewModel.isMediaFlag()) /* viewModel.setMediaFlag(!viewModel.isMediaFlag())
binding.mainActivitySnapshotMediaFlag.isSelected = viewModel.isMediaFlag()*/ binding.mainActivitySnapshotMediaFlag.isSelected = viewModel.isMediaFlag()*/
@ -646,7 +633,6 @@ class MainActivity : BaseActivity() {
/** /**
* 点击上一个轨迹点播放操作 * 点击上一个轨迹点播放操作
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun rewindTraceOnclick() { fun rewindTraceOnclick() {
pausePlayTrace() pausePlayTrace()
val item = val item =
@ -668,7 +654,6 @@ class MainActivity : BaseActivity() {
/** /**
* 点击暂停播放轨迹操作 * 点击暂停播放轨迹操作
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun pauseTraceOnclick() { fun pauseTraceOnclick() {
viewModel.setSelectPauseTrace(!viewModel.isSelectPauseTrace()) viewModel.setSelectPauseTrace(!viewModel.isSelectPauseTrace())
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace() binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
@ -682,8 +667,7 @@ class MainActivity : BaseActivity() {
} }
} }
@RequiresApi(Build.VERSION_CODES.N) private fun playVideo() {
fun playVideo() {
if (mapController.markerHandle.getCurrentMark() == null) { if (mapController.markerHandle.getCurrentMark() == null) {
BaseToast.makeText(this, "请先选择轨迹点!", BaseToast.LENGTH_SHORT).show() BaseToast.makeText(this, "请先选择轨迹点!", BaseToast.LENGTH_SHORT).show()
return return
@ -697,16 +681,14 @@ class MainActivity : BaseActivity() {
/** /**
* 设置为播放状态 * 设置为播放状态
*/ */
@RequiresApi(Build.VERSION_CODES.N) private fun setPlayStatus() {
fun setPlayStatus() {
//切换为播放 //切换为播放
viewModel.setSelectPauseTrace(true) viewModel.setSelectPauseTrace(true)
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace() binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
playVideo() playVideo()
} }
@RequiresApi(Build.VERSION_CODES.N) private fun pauseVideo() {
fun pauseVideo() {
val traceVideoBean = TraceVideoBean(command = "pauseVideo?", userid = Constant.USER_ID) val traceVideoBean = TraceVideoBean(command = "pauseVideo?", userid = Constant.USER_ID)
viewModel.sendServerCommand(this, traceVideoBean, IndoorToolsCommand.STOP) viewModel.sendServerCommand(this, traceVideoBean, IndoorToolsCommand.STOP)
} }
@ -714,7 +696,6 @@ class MainActivity : BaseActivity() {
/** /**
* 点击下一个轨迹点 * 点击下一个轨迹点
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun nextTraceOnclick() { fun nextTraceOnclick() {
pausePlayTrace() pausePlayTrace()
val item = val item =
@ -733,7 +714,6 @@ class MainActivity : BaseActivity() {
} }
} }
@RequiresApi(Build.VERSION_CODES.N)
private fun dealNoData() { private fun dealNoData() {
BaseToast.makeText(this, "无数据了!", Toast.LENGTH_SHORT).show() BaseToast.makeText(this, "无数据了!", Toast.LENGTH_SHORT).show()
@ -746,7 +726,6 @@ class MainActivity : BaseActivity() {
} }
} }
@RequiresApi(Build.VERSION_CODES.N)
fun pausePlayTrace() { fun pausePlayTrace() {
viewModel.setSelectTrace(false) viewModel.setSelectTrace(false)
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace() binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
@ -759,7 +738,6 @@ class MainActivity : BaseActivity() {
* 选点结束 * 选点结束
* @param value true 选点成功 false 选点失败 * @param value true 选点成功 false 选点失败
*/ */
@RequiresApi(Build.VERSION_CODES.N)
private fun selectPointFinish(value: Boolean) { private fun selectPointFinish(value: Boolean) {
if (value) { if (value) {
setViewEnable(true) setViewEnable(true)
@ -773,6 +751,7 @@ class MainActivity : BaseActivity() {
binding.mainActivitySnapshotNext.isEnabled = value binding.mainActivitySnapshotNext.isEnabled = value
binding.mainActivitySnapshotPause.isEnabled = value binding.mainActivitySnapshotPause.isEnabled = value
binding.mainActivitySnapshotFinish.isEnabled = value binding.mainActivitySnapshotFinish.isEnabled = value
viewModel.cancelTrace()
} }
@ -794,16 +773,14 @@ class MainActivity : BaseActivity() {
binding.mainActivityBottomSheetGroup.visibility = View.VISIBLE binding.mainActivityBottomSheetGroup.visibility = View.VISIBLE
mapController.mMapView.setScaleBarLayer(GLViewport.Position.BOTTOM_CENTER, 128, 65) mapController.mMapView.setScaleBarLayer(GLViewport.Position.BOTTOM_CENTER, 128, 65)
} }
mapController.mMapView.vtmMap.animator() mapController.mMapView.vtmMap.animator().animateTo(
.animateTo( GeoPoint(
GeoPoint( mapController.mMapView.vtmMap.mapPosition.geoPoint.latitude,
mapController.mMapView.vtmMap.mapPosition.geoPoint.latitude, mapController.mMapView.vtmMap.mapPosition.geoPoint.longitude
mapController.mMapView.vtmMap.mapPosition.geoPoint.longitude
)
) )
)
} }
@RequiresApi(Build.VERSION_CODES.N)
private fun voiceOnTouchStart() { private fun voiceOnTouchStart() {
viewModel.startSoundMetter(this, binding.mainActivityVoice) viewModel.startSoundMetter(this, binding.mainActivityVoice)
} }
@ -907,7 +884,6 @@ class MainActivity : BaseActivity() {
/** /**
* 打开道路名称属性看板选择的道路在viewmodel里记录不用 * 打开道路名称属性看板选择的道路在viewmodel里记录不用
*/ */
@RequiresApi(Build.VERSION_CODES.N)
fun openRoadNameFragment() { fun openRoadNameFragment() {
if (viewModel.liveDataRoadName.value != null) { if (viewModel.liveDataRoadName.value != null) {
viewModel.showSignMoreInfo(viewModel.liveDataRoadName.value!!) viewModel.showSignMoreInfo(viewModel.liveDataRoadName.value!!)

View File

@ -27,7 +27,11 @@ import com.navinfo.collect.library.data.dao.impl.TraceDataBase
import com.navinfo.collect.library.data.entity.* import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.garminvirbxe.HostBean import com.navinfo.collect.library.garminvirbxe.HostBean
import com.navinfo.collect.library.map.NIMapController import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.map.OnGeoPointClickListener
import com.navinfo.collect.library.map.handler.ONNoteItemClickListener
import com.navinfo.collect.library.map.handler.OnNiLocationItemListener
import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener
import com.navinfo.collect.library.map.handler.OnTaskLinkItemClickListener
import com.navinfo.collect.library.utils.GeometryTools import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.GeometryToolsKt import com.navinfo.collect.library.utils.GeometryToolsKt
import com.navinfo.omqs.Constant import com.navinfo.omqs.Constant
@ -70,7 +74,6 @@ import kotlin.concurrent.fixedRateTimer
* 创建Activity全局viewmode * 创建Activity全局viewmode
*/ */
@RequiresApi(Build.VERSION_CODES.N)
@HiltViewModel @HiltViewModel
class MainViewModel @Inject constructor( class MainViewModel @Inject constructor(
private val mapController: NIMapController, private val mapController: NIMapController,
@ -78,7 +81,10 @@ class MainViewModel @Inject constructor(
private val realmOperateHelper: RealmOperateHelper, private val realmOperateHelper: RealmOperateHelper,
private val networkService: NetworkService, private val networkService: NetworkService,
private val sharedPreferences: SharedPreferences private val sharedPreferences: SharedPreferences
) : ViewModel(), SocketServer.OnConnectSinsListener { ) : ViewModel(), SocketServer.OnConnectSinsListener,
SharedPreferences.OnSharedPreferenceChangeListener {
private val TAG = "MainViewModel"
private var mCameraDialog: CommonDialog? = null private var mCameraDialog: CommonDialog? = null
@ -110,6 +116,16 @@ class MainViewModel @Inject constructor(
private var traceTag: String = "TRACE_TAG" private var traceTag: String = "TRACE_TAG"
/**
* 右上角菜单状态
*/
val liveDataMenuState = MutableLiveData<Boolean>()
/**
* 地图中心坐标
*/
val liveDataCenterPoint = MutableLiveData<MapPosition>()
// var testPoint = GeoPoint(0, 0) // var testPoint = GeoPoint(0, 0)
//uuid标识用于记录轨迹组 //uuid标识用于记录轨迹组
@ -129,9 +145,7 @@ class MainViewModel @Inject constructor(
var captureLinkState: Boolean = false var captureLinkState: Boolean = false
val liveDataMenuState = MutableLiveData<Boolean>() var currentTaskBean: TaskBean? = null
val liveDataCenterPoint = MutableLiveData<MapPosition>()
//状态 //状态
val liveIndoorToolsResp: MutableLiveData<IndoorToolsResp> = MutableLiveData() val liveIndoorToolsResp: MutableLiveData<IndoorToolsResp> = MutableLiveData()
@ -173,9 +187,10 @@ class MainViewModel @Inject constructor(
private var timer: Timer? = null private var timer: Timer? = null
private var disTime :Long = 1000 private var disTime: Long = 1000
init { init {
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition -> mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
when (e) { when (e) {
Map.SCALE_EVENT, Map.MOVE_EVENT, Map.ROTATE_EVENT -> liveDataCenterPoint.value = Map.SCALE_EVENT, Map.MOVE_EVENT, Map.ROTATE_EVENT -> liveDataCenterPoint.value =
@ -183,74 +198,118 @@ class MainViewModel @Inject constructor(
} }
}) })
//处理质检数据点击事件
mapController.markerHandle.setOnQsRecordItemClickListener(object :
OnQsRecordItemClickListener {
override fun onQsRecordList(list: MutableList<String>) {
liveDataQsRecordIdList.value = list
}
override fun onNote(id: String) {
liveDataNoteId.value = id
}
override fun onNiLocation(index: Int, item: NiLocation) {
liveDataNILocationList.value = item
}
})
shareUtil = ShareUtil(mapController.mMapView.context, 1) shareUtil = ShareUtil(mapController.mMapView.context, 1)
initLocation() initLocation()
/**
* 处理点击道路捕捉回调功能
*/
mapController.mMapView.addOnNIMapClickListener(
TAG,
//处理地图点击操作
object : OnGeoPointClickListener {
override fun onMapClick(tag: String, point: GeoPoint) {
if (tag == TAG) {
viewModelScope.launch(Dispatchers.Default) {
//线选择状态
if (bSelectRoad) {
captureLink(point)
}
}
}
}
},
/**
* 处理之间数据的点击
*/
object : OnQsRecordItemClickListener {
override fun onQsRecordList(tag: String, list: MutableList<String>) {
if (tag == TAG)
liveDataQsRecordIdList.value = list
}
},
/**
* 处理新增link线点击编辑
*/
object : OnTaskLinkItemClickListener {
override fun onTaskLink(tag: String, taskLinkId: String) {
if (tag == TAG)
liveDataTaskLink.value = taskLinkId
}
},
/**
* 处理便签点击
*/
object : ONNoteItemClickListener {
override fun onNote(tag: String, noteId: String) {
if (tag == TAG)
liveDataNoteId.value = noteId
}
//处理地图点击操作 },
viewModelScope.launch(Dispatchers.Default) { /**
mapController.onMapClickFlow.collectLatest { * 处理定位点的点击
// testPoint = it */
//线选择状态 object : OnNiLocationItemListener {
if (bSelectRoad) { override fun onNiLocation(tag: String, index: Int, it: NiLocation) {
captureLink(it) if (tag == TAG)
} else { liveDataNILocationList.value = it
captureItem(it)
} }
} }
} )
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
initTaskData() getTaskBean()
//初始化选中的任务高亮高亮
mapController.lineHandler.showTaskLines(currentTaskBean?.hadLinkDvoList!!)
initQsRecordData() initQsRecordData()
initNoteData() initNoteData()
initNILocationData() initNILocationData()
} }
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
socketServer = SocketServer(mapController, traceDataBase, sharedPreferences) socketServer = SocketServer(mapController, traceDataBase, sharedPreferences)
} }
/** /**
* 初始化选中的任务高亮高亮 * 获取当前任务
*/ */
private suspend fun initTaskData() { private suspend fun getTaskBean() {
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1) val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst() val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
if (res != null) { if (res != null) {
val taskBean = realm.copyFromRealm(res) currentTaskBean = realm.copyFromRealm(res)
mapController.lineHandler.showTaskLines(taskBean.hadLinkDvoList)
} }
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
if (key == Constant.SELECT_TASK_ID) {
viewModelScope.launch(Dispatchers.IO) {
getTaskBean()
initQsRecordData()
}
}
} }
/** /**
* 初始化渲染质检数据 * 初始化渲染质检数据
*/ */
private suspend fun initQsRecordData() { private suspend fun initQsRecordData() {
var list = mutableListOf<QsRecordBean>() if (currentTaskBean != null) {
val realm = Realm.getDefaultInstance() var list = mutableListOf<QsRecordBean>()
realm.executeTransaction { val realm = Realm.getDefaultInstance()
val objects = realm.where<QsRecordBean>().findAll() realm.executeTransaction {
list = realm.copyFromRealm(objects) val objects =
} realm.where<QsRecordBean>().equalTo("taskId", currentTaskBean!!.id).findAll()
for (item in list) { list = realm.copyFromRealm(objects)
mapController.markerHandle.addOrUpdateQsRecordMark(item) }
mapController.markerHandle.removeAllQsMarker()
for (item in list) {
mapController.markerHandle.addOrUpdateQsRecordMark(item)
}
} }
} }
@ -288,7 +347,6 @@ class MainViewModel @Inject constructor(
/** /**
* 初始化定位信息 * 初始化定位信息
*/ */
@RequiresApi(Build.VERSION_CODES.N)
private fun initLocation() { private fun initLocation() {
//用于定位点存储到数据库 //用于定位点存储到数据库
@ -360,10 +418,10 @@ class MainViewModel @Inject constructor(
) )
) )
} }
withContext(Dispatchers.Main){ withContext(Dispatchers.Main) {
if(Constant.AUTO_LOCATION){ if (Constant.AUTO_LOCATION) {
mapController.mMapView.vtmMap.animator() mapController.mMapView.vtmMap.animator()
.animateTo(GeoPoint( location.longitude, location.latitude)) .animateTo(GeoPoint(location.longitude, location.latitude))
} }
} }
} }
@ -372,17 +430,10 @@ class MainViewModel @Inject constructor(
mapController.layerManagerHandler.showNiLocationLayer() mapController.layerManagerHandler.showNiLocationLayer()
} }
/**
* 捕捉要素
*/
private suspend fun captureItem(point: GeoPoint) {
}
/** /**
* 捕获道路和面板 * 捕获道路和面板
*/ */
@RequiresApi(Build.VERSION_CODES.N)
private suspend fun captureLink(point: GeoPoint) { private suspend fun captureLink(point: GeoPoint) {
if (captureLinkState) { if (captureLinkState) {
return return
@ -391,101 +442,103 @@ class MainViewModel @Inject constructor(
try { try {
captureLinkState = true captureLinkState = true
val linkList = realmOperateHelper.queryLink( if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
point = point, val linkList = realmOperateHelper.queryLink(
) point = point,
var hisRoadName = false )
if (linkList.isNotEmpty()) {
//看板数据
val signList = mutableListOf<SignBean>()
val topSignList = mutableListOf<SignBean>()
mapController.lineHandler.linksLayer.clear()
val link = linkList[0] var hisRoadName = false
if (linkList.isNotEmpty()) {
//看板数据
val signList = mutableListOf<SignBean>()
val topSignList = mutableListOf<SignBean>()
mapController.lineHandler.linksLayer.clear()
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid] val link = linkList[0]
if (linkIdCache != linkId) { val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
mapController.lineHandler.showLine(link.geometry) if (linkIdCache != linkId) {
linkId?.let {
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
for (element in elementList) {
if (element.code == 2011) { mapController.lineHandler.showLine(link.geometry)
hisRoadName = true linkId?.let {
liveDataRoadName.postValue(element) var elementList = realmOperateHelper.queryLinkByLinkPid(it)
continue for (element in elementList) {
}
val distance = GeometryTools.distanceToDouble( if (element.code == 2011) {
point, GeometryTools.createGeoPoint(element.geometry) hisRoadName = true
) liveDataRoadName.postValue(element)
continue
}
val signBean = SignBean( val distance = GeometryTools.distanceToDouble(
iconId = SignUtil.getSignIcon(element), point, GeometryTools.createGeoPoint(element.geometry)
iconText = SignUtil.getSignIconText(element),
distance = distance.toInt(),
linkId = linkId,
name = SignUtil.getSignNameText(element),
bottomRightText = SignUtil.getSignBottomRightText(element),
renderEntity = element,
isMoreInfo = SignUtil.isMoreInfo(element),
index = SignUtil.getRoadInfoIndex(element)
)
Log.e("jingo", "捕捉到的数据code ${element.code}")
when (element.code) {
//车道数,种别,功能等级,线限速,道路方向
2041, 2008, 2002, 2019, 2010 -> topSignList.add(
signBean
) )
4002, 4003, 4004, 4010, 4022, 4601 -> signList.add( val signBean = SignBean(
signBean iconId = SignUtil.getSignIcon(element),
iconText = SignUtil.getSignIconText(element),
distance = distance.toInt(),
linkId = linkId,
name = SignUtil.getSignNameText(element),
bottomRightText = SignUtil.getSignBottomRightText(element),
renderEntity = element,
isMoreInfo = SignUtil.isMoreInfo(element),
index = SignUtil.getRoadInfoIndex(element)
) )
Log.e("jingo", "捕捉到的数据code ${element.code}")
when (element.code) {
//车道数,种别,功能等级,线限速,道路方向
2041, 2008, 2002, 2019, 2010 -> topSignList.add(
signBean
)
4002, 4003, 4004, 4010, 4022, 4601 -> signList.add(
signBean
)
}
} }
} val realm = Realm.getDefaultInstance()
val entity = realm.where(RenderEntity::class.java)
val realm = Realm.getDefaultInstance() .equalTo("table", "OMDB_RESTRICTION").and().equalTo(
val entity = realm.where(RenderEntity::class.java) "properties['linkIn']", it
.equalTo("table", "OMDB_RESTRICTION").and().equalTo(
"properties['linkIn']", it
).findFirst()
if (entity != null) {
val outLink = entity.properties["linkOut"]
val linkOutEntity = realm.where(RenderEntity::class.java)
.equalTo("table", "OMDB_RD_LINK").and().equalTo(
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
outLink
).findFirst() ).findFirst()
if (linkOutEntity != null) { if (entity != null) {
mapController.lineHandler.linksLayer.addLine( val outLink = entity.properties["linkOut"]
linkOutEntity.geometry, 0x7DFF0000 val linkOutEntity = realm.where(RenderEntity::class.java)
) .equalTo("table", "OMDB_RD_LINK").and().equalTo(
"properties['${RenderEntity.Companion.LinkTable.linkPid}']",
outLink
).findFirst()
if (linkOutEntity != null) {
mapController.lineHandler.linksLayer.addLine(
linkOutEntity.geometry, 0x7DFF0000
)
}
} }
} }
}
liveDataTopSignList.postValue(topSignList.distinctBy { it.name } liveDataTopSignList.postValue(topSignList.distinctBy { it.name }
.sortedBy { it.index }) .sortedBy { it.index })
liveDataSignList.postValue(signList.sortedBy { it.distance }) liveDataSignList.postValue(signList.sortedBy { it.distance })
val speechText = SignUtil.getRoadSpeechText(topSignList) val speechText = SignUtil.getRoadSpeechText(topSignList)
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
speakMode?.speakText(speechText) speakMode?.speakText(speechText)
}
linkIdCache = linkId ?: ""
} }
linkIdCache = linkId ?: "" } else {
mapController.lineHandler.removeLine()
linkIdCache = ""
}
//如果没有捕捉到道路名
if (!hisRoadName) {
liveDataRoadName.postValue(null)
} }
} else {
mapController.lineHandler.removeLine()
linkIdCache = ""
} }
//如果没有捕捉到道路名
if (!hisRoadName) {
liveDataRoadName.postValue(null)
}
} catch (e: Exception) { } catch (e: Exception) {
} finally { } finally {
@ -511,9 +564,9 @@ class MainViewModel @Inject constructor(
override fun onCleared() { override fun onCleared() {
super.onCleared() super.onCleared()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
mapController.lineHandler.removeLine() mapController.mMapView.removeOnNIMapClickListener(TAG)
} mapController.lineHandler.removeLine()
} }
//点击相机按钮 //点击相机按钮
@ -547,7 +600,7 @@ class MainViewModel @Inject constructor(
}) })
} }
private fun initCameraDialog(context:Context){ private fun initCameraDialog(context: Context) {
if (mCameraDialog == null) { if (mCameraDialog == null) {
mCameraDialog = CommonDialog( mCameraDialog = CommonDialog(
context, context,
@ -853,10 +906,10 @@ class MainViewModel @Inject constructor(
* @param niLocation 轨迹点 * @param niLocation 轨迹点
*/ */
fun setCurrentIndexNiLocation(niLocation: NiLocation) { fun setCurrentIndexNiLocation(niLocation: NiLocation) {
viewModelScope.launch ( Dispatchers.IO ){ viewModelScope.launch(Dispatchers.IO) {
Log.e("qj","开始$currentIndexNiLocation") Log.e("qj", "开始$currentIndexNiLocation")
currentIndexNiLocation = mapController.markerHandle.getNILocationIndex(niLocation)!! currentIndexNiLocation = mapController.markerHandle.getNILocationIndex(niLocation)!!
Log.e("qj","结束$currentIndexNiLocation") Log.e("qj", "结束$currentIndexNiLocation")
} }
} }
@ -907,7 +960,7 @@ class MainViewModel @Inject constructor(
if (mNiLocation != null) { if (mNiLocation != null) {
setCurrentIndexNiLocation(mNiLocation) setCurrentIndexNiLocation(mNiLocation)
showMarker(mapController.mMapView.context, mNiLocation) showMarker(mapController.mMapView.context, mNiLocation)
Log.e("qj","反向控制$currentIndexNiLocation") Log.e("qj", "反向控制$currentIndexNiLocation")
} else { } else {
BaseToast.makeText( BaseToast.makeText(
mapController.mMapView.context, mapController.mMapView.context,
@ -917,12 +970,12 @@ class MainViewModel @Inject constructor(
} }
} }
fun isAutoCamera():Boolean{ fun isAutoCamera(): Boolean {
return shareUtil?.connectstate == true return shareUtil?.connectstate == true
} }
fun autoCamera(){ fun autoCamera() {
if (shareUtil?.connectstate == true) { if (shareUtil?.connectstate == true) {
val hostBean1 = HostBean() val hostBean1 = HostBean()
hostBean1.ipAddress = shareUtil!!.takeCameraIP hostBean1.ipAddress = shareUtil!!.takeCameraIP
@ -933,28 +986,30 @@ class MainViewModel @Inject constructor(
} }
fun startTimer() { fun startTimer() {
if(timer!=null){ if (timer != null) {
cancelTrace() cancelTrace()
} }
timer = fixedRateTimer("", false, disTime, disTime) { timer = fixedRateTimer("", false, disTime, disTime) {
if(currentIndexNiLocation<mapController.markerHandle.getNILocationItemizedLayerSize()){ if (currentIndexNiLocation < mapController.markerHandle.getNILocationItemizedLayerSize()) {
Log.e("qj","定时器") Log.e("qj", "定时器")
val niLocation = mapController.markerHandle.getNILocation(currentIndexNiLocation) val niLocation = mapController.markerHandle.getNILocation(currentIndexNiLocation)
val nextNiLocation = mapController.markerHandle.getNILocation(currentIndexNiLocation+1) val nextNiLocation =
if(nextNiLocation!=null&&niLocation!=null){ mapController.markerHandle.getNILocation(currentIndexNiLocation + 1)
var nilocationDisTime = nextNiLocation.timeStamp.toLong() - niLocation.timeStamp.toLong() if (nextNiLocation != null && niLocation != null) {
disTime = if(nilocationDisTime<1000){ var nilocationDisTime =
nextNiLocation.timeStamp.toLong() - niLocation.timeStamp.toLong()
disTime = if (nilocationDisTime < 1000) {
1000 1000
}else{ } else {
nilocationDisTime nilocationDisTime
} }
showMarker(mapController.mMapView.context,nextNiLocation) showMarker(mapController.mMapView.context, nextNiLocation)
currentIndexNiLocation += 1 currentIndexNiLocation += 1
//再次启动 //再次启动
startTimer() startTimer()
} }
}else{ } else {
Toast.makeText(mapController.mMapView.context,"无数据了!",Toast.LENGTH_LONG).show() Toast.makeText(mapController.mMapView.context, "无数据了!", Toast.LENGTH_LONG).show()
cancelTrace() cancelTrace()
} }
} }

View File

@ -8,6 +8,7 @@ import android.os.Bundle
import android.provider.MediaStore import android.provider.MediaStore
import android.util.Log import android.util.Log
import android.view.* import android.view.*
import android.widget.Toast
import androidx.activity.result.ActivityResult import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
@ -44,7 +45,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
mCameraLauncher = registerForActivityResult<Intent, ActivityResult>( mCameraLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult() ActivityResultContracts.StartActivityForResult()
) { result: ActivityResult -> ) { result: ActivityResult ->
if (result.resultCode == Activity.RESULT_OK) { if (result.resultCode == Activity.RESULT_OK) {
@ -65,37 +66,28 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
binding = binding =
DataBindingUtil.inflate(inflater, R.layout.fragment_evaluation_result, container, false) DataBindingUtil.inflate(inflater, R.layout.fragment_evaluation_result, container, false)
binding.fragment = this binding.fragment = this
val layoutManager = LinearLayoutManager(context)
binding.viewModel = viewModel binding.viewModel = viewModel
binding.lifecycleOwner = this binding.lifecycleOwner = this
//// 设置 RecyclerView 的固定大小,避免在滚动时重新计算视图大小和布局,提高性能
binding.evaluationVoiceRecyclerview.setHasFixedSize(true)
binding.evaluationVoiceRecyclerview.layoutManager = layoutManager
/**
* 监听左侧栏的点击事件
*/
val adapter = SoundtListAdapter { _, view ->
}
binding.evaluationVoiceRecyclerview.adapter = adapter
viewModel.listDataChatMsgEntityList.observe(viewLifecycleOwner) {
adapter.refreshData(it)
}
return binding.root return binding.root
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
//监听是否退出当前页面 //// 设置 RecyclerView 的固定大小,避免在滚动时重新计算视图大小和布局,提高性能
viewModel.liveDataFinish.observe(viewLifecycleOwner) { binding.evaluationVoiceRecyclerview.setHasFixedSize(true)
onBackPressed() val layoutManager = LinearLayoutManager(context)
binding.evaluationVoiceRecyclerview.layoutManager = layoutManager
/**
* 监听左侧栏的点击事件
*/
val adapter = SoundtListAdapter { _, _ ->
} }
binding.evaluationVoiceRecyclerview.adapter = adapter
//返回按钮点击 //返回按钮点击
binding.evaluationBar.setOnClickListener() { binding.evaluationBar.setOnClickListener {
val mDialog = FirstDialog(context) val mDialog = FirstDialog(context)
mDialog.setTitle("提示?") mDialog.setTitle("提示?")
mDialog.setMessage("是否退出,请确认!") mDialog.setMessage("是否退出,请确认!")
@ -110,15 +102,13 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
} }
//保存事件 //保存事件
binding.evaluationBarSave.setOnClickListener() { binding.evaluationBarSave.setOnClickListener {
viewModel.saveData() viewModel.saveData()
} }
//删除事件 //删除事件
binding.evaluationBarDelete.setOnClickListener() { binding.evaluationBarDelete.setOnClickListener {
viewModel.deleteData(requireContext()) viewModel.deleteData(requireContext())
} }
/** /**
* 照片view * 照片view
@ -166,22 +156,21 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
/** /**
* 读取元数据 * 读取元数据
*/ */
// val id = args.qsId
var id = "" var id = ""
var signBean: SignBean? = null var signBean: SignBean? = null
var autoSave: Boolean = false var autoSave = false
var filePath: String = "" var filePath = ""
arguments?.let { arguments?.let {
id = it.getString("QsId", "") id = it.getString("QsId", "")
filePath = it.getString("filePath", "") filePath = it.getString("filePath", "")
try { try {
signBean = it.getParcelable("SignBean") signBean = it.getParcelable("SignBean")
autoSave = it.getBoolean("AutoSave") autoSave = it.getBoolean("AutoSave")
} catch (e: java.lang.Exception) { } catch (_: java.lang.Exception) {
} }
} }
if (id == null || id.isEmpty()) { if (id.isEmpty()) {
viewModel.initNewData(signBean, filePath) viewModel.initNewData(signBean, filePath)
//增加监听,联动列表自动保存 //增加监听,联动列表自动保存
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) { viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
@ -192,102 +181,22 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
} else { } else {
viewModel.initData(id) viewModel.initData(id)
} }
// //监听大分类数据变化
// viewModel.liveDataClassTypeList.observe(viewLifecycleOwner) {
// if (it == null || it.isEmpty()) {
// Toast.makeText(requireContext(), "还没有导入元数据!", Toast.LENGTH_SHORT).show()
// } else {
// binding.evaluationClassType.adapter =
// ArrayAdapter(requireContext(), R.layout.text_item_select, it)
// }
// }
//
// viewModel.liveDataProblemTypeList.observe(viewLifecycleOwner){
// if (it == null || it.isEmpty()) {
// Toast.makeText(requireContext(), "还没有导入元数据!", Toast.LENGTH_SHORT).show()
// }else{
// binding.evaluationProblemType.adapter =
// ArrayAdapter(requireContext(), R.layout.text_item_select, it)
// }
// }
// //选择问题分类的回调 viewModel.listDataChatMsgEntityList.observe(viewLifecycleOwner) {
// binding.evaluationClassType.onItemSelectedListener = adapter.refreshData(it)
// object : AdapterView.OnItemSelectedListener { }
// override fun onItemSelected(
// parent: AdapterView<*>?, view: View?, position: Int, id: Long //监听是否退出当前页面
// ) { viewModel.liveDataFinish.observe(viewLifecycleOwner) {
// viewModel.getProblemTypeList(position) onBackPressed()
// } }
// //监听要提示的信息
// override fun onNothingSelected(parent: AdapterView<*>?) {} viewModel.liveDataToastMessage.observe(viewLifecycleOwner) {
// } Toast.makeText(requireContext(), it, Toast.LENGTH_SHORT).show()
// /** }
// * 监听联动选择的内容
// */
// viewModel.problemTypeListLiveData.observe(viewLifecycleOwner) {
// binding.evaluationClassTabLayout.let { tabLayout ->
// tabLayout.removeAllTabs()
// val fragmentList = mutableListOf<Fragment>()
// for (item in it) {
// val tab = tabLayout.newTab()
// tab.text = item
// tabLayout.addTab(tab)
// fragmentList.add(PhenomenonFragment(viewModel.currentClassType, item))
// }
// phenomenonFragmentAdapter =
// activity?.let { a -> EvaluationResultAdapter(a, fragmentList) }
// binding.evaluationViewpager.adapter = phenomenonFragmentAdapter
//
// TabLayoutMediator(
// binding.evaluationClassTabLayout,
// binding.evaluationViewpager
// ) { tab, position ->
// tab.text = it[position]
// }.attach()
// updateHeight(0)
// }
//
// }
// binding.evaluationViewpager.registerOnPageChangeCallback(object :
// ViewPager2.OnPageChangeCallback() {
// override fun onPageSelected(position: Int) {
// super.onPageSelected(position)
// updateHeight(position)
// }
// })
} }
// private fun updateHeight(position: Int) {
// phenomenonFragmentAdapter?.let {
// if (it.fragmentList.size > position) {
// val fragment: Fragment = it.fragmentList[position]
// if (fragment.view != null) {
// val viewWidth = View.MeasureSpec.makeMeasureSpec(
// fragment.requireView().width, View.MeasureSpec.EXACTLY
// )
// val viewHeight =
// View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)
// fragment.requireView().measure(viewWidth, viewHeight)
// binding.evaluationViewpager.let { viewpager ->
// if (viewpager.layoutParams.height != fragment.requireView().measuredHeight) {
// //必须要用对象去接收,然后修改该对象再采用该对象,否则无法生效...
// val layoutParams: ViewGroup.LayoutParams =
// viewpager.layoutParams
// layoutParams.height = fragment.requireView().measuredHeight
// viewpager.layoutParams = layoutParams
// }
// }
//
// }
// }
// }
//
// }
override fun onDestroyView() { override fun onDestroyView() {
activity?.run { activity?.run {
findNavController(R.id.main_activity_middle_fragment).navigateUp() findNavController(R.id.main_activity_middle_fragment).navigateUp()
@ -307,6 +216,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
if (currentItem > 0) { if (currentItem > 0) {
binding.evaluationPictureViewpager.currentItem = currentItem - 1 binding.evaluationPictureViewpager.currentItem = currentItem - 1
} else { } else {
return
} }
} }
@ -316,7 +226,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
if (currentItem < pictureAdapter.data.size - 1) { if (currentItem < pictureAdapter.data.size - 1) {
binding.evaluationPictureViewpager.currentItem = currentItem + 1 binding.evaluationPictureViewpager.currentItem = currentItem + 1
} else { } else {
return
} }
} }
//上三项,打开面板 //上三项,打开面板
@ -369,7 +279,9 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
R.id.evaluation_camera -> { R.id.evaluation_camera -> {
takePhoto() takePhoto()
} }
else -> {} else -> {
return
}
} }
} }
} }
@ -402,6 +314,4 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
Log.d("TTTT", e.toString()) Log.d("TTTT", e.toString())
} }
} }
} }

View File

@ -3,6 +3,7 @@ package com.navinfo.omqs.ui.fragment.evaluationresult
import android.app.Activity import android.app.Activity
import android.app.Dialog import android.app.Dialog
import android.content.Context import android.content.Context
import android.content.SharedPreferences
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.drawable.AnimationDrawable import android.graphics.drawable.AnimationDrawable
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
@ -20,9 +21,12 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.blankj.utilcode.util.ToastUtils import com.blankj.utilcode.util.ToastUtils
import com.navinfo.collect.library.data.entity.AttachmentBean import com.navinfo.collect.library.data.entity.AttachmentBean
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.collect.library.data.entity.QsRecordBean import com.navinfo.collect.library.data.entity.QsRecordBean
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.collect.library.map.NIMapController import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.map.OnGeoPointClickListener
import com.navinfo.collect.library.utils.GeometryTools import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.omqs.Constant import com.navinfo.omqs.Constant
import com.navinfo.omqs.R import com.navinfo.omqs.R
@ -39,8 +43,8 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import io.realm.Realm import io.realm.Realm
import io.realm.RealmList import io.realm.RealmList
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.oscim.core.GeoPoint import org.oscim.core.GeoPoint
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
@ -52,9 +56,11 @@ class EvaluationResultViewModel @Inject constructor(
private val roomAppDatabase: RoomAppDatabase, private val roomAppDatabase: RoomAppDatabase,
private val mapController: NIMapController, private val mapController: NIMapController,
private val realmOperateHelper: RealmOperateHelper, private val realmOperateHelper: RealmOperateHelper,
) : ViewModel() { private val sharedPreferences: SharedPreferences
) : ViewModel(), SharedPreferences.OnSharedPreferenceChangeListener {
private val markerTitle = "点选marker"
private val TAG = "点选marker"
/** /**
* 操作结束销毁页面 * 操作结束销毁页面
@ -66,10 +72,6 @@ class EvaluationResultViewModel @Inject constructor(
*/ */
val liveDataLeftTypeList = MutableLiveData<List<ScProblemTypeBean>>() val liveDataLeftTypeList = MutableLiveData<List<ScProblemTypeBean>>()
/**
* 问题类型 liveData [MiddleAdapter]展示的数据
*/
// val liveDataMiddleTypeList = MutableLiveData<List<String>>()
/** /**
* 问题现象 liveData [RightGroupHeaderAdapter]展示的数据 * 问题现象 liveData [RightGroupHeaderAdapter]展示的数据
@ -77,9 +79,9 @@ class EvaluationResultViewModel @Inject constructor(
val liveDataRightTypeList = MutableLiveData<List<RightBean>>() val liveDataRightTypeList = MutableLiveData<List<RightBean>>()
/** /**
* * 要保存的评测数据
*/ */
val liveDataQsRecordBean = MutableLiveData<QsRecordBean>() val liveDataQsRecordBean = MutableLiveData(QsRecordBean(id = UUID.randomUUID().toString()))
/** /**
* 语音列表 * 语音列表
@ -91,6 +93,19 @@ class EvaluationResultViewModel @Inject constructor(
*/ */
val liveDataPictureList = MutableLiveData<MutableList<String>>() val liveDataPictureList = MutableLiveData<MutableList<String>>()
/**
* toast信息
*/
val liveDataToastMessage = MutableLiveData<String>()
/**
* 当前选择的任务
*/
val liveDataTaskBean = MutableLiveData<TaskBean>()
/**
* 编辑数据时用来差分数据
*/
var oldBean: QsRecordBean? = null var oldBean: QsRecordBean? = null
//语音窗体 //语音窗体
@ -108,24 +123,27 @@ class EvaluationResultViewModel @Inject constructor(
var classCodeTemp: String = "" var classCodeTemp: String = ""
init { init {
liveDataQsRecordBean.value = QsRecordBean(id = UUID.randomUUID().toString()) mapController.mMapView.addOnNIMapClickListener(TAG, object : OnGeoPointClickListener {
viewModelScope.launch { override fun onMapClick(tag: String, point: GeoPoint) {
mapController.onMapClickFlow.collectLatest { if (tag == TAG) {
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText() liveDataQsRecordBean.value!!.geometry =
mapController.markerHandle.addMarker(it, markerTitle) GeometryTools.createGeometry(point).toText()
viewModelScope.launch { mapController.markerHandle.addMarker(point, TAG)
captureLink(it.longitude, it.latitude) viewModelScope.launch {
captureLink(point)
}
} }
} }
} })
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
} }
override fun onCleared() { override fun onCleared() {
super.onCleared() super.onCleared()
mapController.markerHandle.removeMarker(markerTitle) mapController.mMapView.removeOnNIMapClickListener(TAG)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { mapController.markerHandle.removeMarker(TAG)
mapController.lineHandler.removeLine() mapController.lineHandler.removeLine()
}
} }
@ -133,40 +151,57 @@ class EvaluationResultViewModel @Inject constructor(
* 查询数据库获取问题分类 * 查询数据库获取问题分类
*/ */
fun initNewData(bean: SignBean?, filePath: String) { fun initNewData(bean: SignBean?, filePath: String) {
//获取当前定位点
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
//如果不是从面板进来的
if (bean == null) {
geoPoint?.let {
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
mapController.markerHandle.addMarker(geoPoint, markerTitle)
mapController.animationHandler.animationByLatLon(
geoPoint.latitude, geoPoint.longitude
)
viewModelScope.launch {
captureLink(geoPoint.longitude, geoPoint.latitude)
}
}
} else {
liveDataQsRecordBean.value?.run {
elementId = bean.renderEntity.code.toString()
linkId = bean.linkId
if (linkId.isNotEmpty()) {
viewModelScope.launch {
val link = realmOperateHelper.queryLink(linkId)
link?.let { l ->
mapController.lineHandler.showLine(l.geometry)
}
}
}
val point = GeometryTools.createGeoPoint(bean.renderEntity.geometry)
this.geometry = GeometryTools.createGeometry(point).toText()
mapController.animationHandler.animationByLatLon(point.latitude, point.longitude)
mapController.markerHandle.addMarker(point, markerTitle)
}
}
//查询元数据 //查询元数据
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
/**
* 获取当前所选的任务
*/
val taskId = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
val realm = Realm.getDefaultInstance()
val objects = realm.where(TaskBean::class.java).equalTo("id", taskId).findFirst()
if (objects != null) {
liveDataTaskBean.postValue(realm.copyFromRealm(objects))
}
//获取当前定位点
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
//如果不是从面板进来的
if (bean == null) {
geoPoint?.let {
liveDataQsRecordBean.value!!.geometry =
GeometryTools.createGeometry(it).toText()
withContext(Dispatchers.Main) {
mapController.markerHandle.addMarker(geoPoint, TAG)
mapController.animationHandler.animationByLatLon(
geoPoint.latitude, geoPoint.longitude
)
}
captureLink(geoPoint)
}
} else {
liveDataQsRecordBean.value?.run {
elementId = bean.renderEntity.code.toString()
linkId = bean.linkId
if (linkId.isNotEmpty()) {
viewModelScope.launch {
val link = realmOperateHelper.queryLink(linkId)
link?.let { l ->
mapController.lineHandler.showLine(l.geometry)
}
}
}
val point = GeometryTools.createGeoPoint(bean.renderEntity.geometry)
this.geometry = GeometryTools.createGeometry(point).toText()
withContext(Dispatchers.Main) {
mapController.animationHandler.animationByLatLon(
point.latitude, point.longitude
)
mapController.markerHandle.addMarker(point, TAG)
}
}
}
getClassTypeList(bean) getClassTypeList(bean)
getProblemLinkList() getProblemLinkList()
} }
@ -174,23 +209,32 @@ class EvaluationResultViewModel @Inject constructor(
} }
/** /**
* 捕捉道路 * 捕捉道路或新增评测link
*/ */
private suspend fun captureLink(longitude: Double, latitude: Double) { private suspend fun captureLink(point: GeoPoint) {
if (liveDataTaskBean.value == null) {
liveDataToastMessage.postValue("请先选择所属任务!")
return
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val linkList = realmOperateHelper.queryLink(
point = GeoPoint(latitude, longitude),
)
liveDataQsRecordBean.value?.let { liveDataQsRecordBean.value?.let {
if (linkList.isNotEmpty()) {
it.linkId = linkList[0].properties[LinkTable.linkPid] ?: "" val taskLink =
mapController.lineHandler.showLine(linkList[0].geometry) realmOperateHelper.captureTaskLink(liveDataTaskBean.value!!.id, point)
Log.e("jingo", "捕捉到的linkId = ${it.linkId}") if (taskLink != null) {
it.linkId = taskLink.linkPid
mapController.lineHandler.showLine(taskLink.geometry)
return
} else { } else {
it.linkId = "" val linkList = realmOperateHelper.queryLink(point = point)
mapController.lineHandler.removeLine() if (linkList.isNotEmpty()) {
it.linkId = linkList[0].properties[LinkTable.linkPid] ?: ""
mapController.lineHandler.showLine(linkList[0].geometry)
return
}
} }
it.linkId = ""
mapController.lineHandler.removeLine()
} }
} }
} }
@ -325,20 +369,52 @@ class EvaluationResultViewModel @Inject constructor(
liveDataQsRecordBean.postValue(liveDataQsRecordBean.value) liveDataQsRecordBean.postValue(liveDataQsRecordBean.value)
} }
/**
* 保存数据
*/
fun saveData() { fun saveData() {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
val taskBean = liveDataQsRecordBean.value!!
if (liveDataTaskBean.value == null) {
liveDataToastMessage.postValue("请选择所属任务!")
return@launch
} else if (taskBean.classType.isEmpty()) {
liveDataToastMessage.postValue("请选择要素分类!")
return@launch
} else if (taskBean.problemType.isEmpty()) {
liveDataToastMessage.postValue("请选择问题类型!")
return@launch
} else if (taskBean.phenomenon.isEmpty()) {
liveDataToastMessage.postValue("请选择问题现象!")
return@launch
} else if (taskBean.problemLink.isEmpty()) {
liveDataToastMessage.postValue("请选择问题环节!")
return@launch
} else if (taskBean.classType.isEmpty()) {
liveDataToastMessage.postValue("请选择问题分类!")
return@launch
} else if (taskBean.cause.isEmpty()) {
liveDataToastMessage.postValue("请选择初步分析原因!")
return@launch
}
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
liveDataQsRecordBean.value!!.taskId = liveDataTaskBean.value!!.id
liveDataQsRecordBean.value!!.checkTime = DateTimeUtil.getDataTime() liveDataQsRecordBean.value!!.checkTime = DateTimeUtil.getDataTime()
liveDataQsRecordBean.value!!.checkUserId = Constant.USER_REAL_NAME liveDataQsRecordBean.value!!.checkUserId = Constant.USER_REAL_NAME
realm.executeTransaction { realm.executeTransaction {
it.copyToRealmOrUpdate(liveDataQsRecordBean.value) it.copyToRealmOrUpdate(liveDataQsRecordBean.value)
} }
// realm.close()
mapController.markerHandle.addOrUpdateQsRecordMark(liveDataQsRecordBean.value!!) mapController.markerHandle.addOrUpdateQsRecordMark(liveDataQsRecordBean.value!!)
liveDataFinish.postValue(true) liveDataFinish.postValue(true)
} }
} }
/**
* 删除数据
*/
fun deleteData(context: Context) { fun deleteData(context: Context) {
val mDialog = FirstDialog(context) val mDialog = FirstDialog(context)
mDialog.setTitle("提示?") mDialog.setTitle("提示?")
@ -371,194 +447,219 @@ class EvaluationResultViewModel @Inject constructor(
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
Realm.getDefaultInstance().use { realm -> val realm = Realm.getDefaultInstance()
realm.executeTransactionAsync { bgRealm -> val objects = realm.where(QsRecordBean::class.java).equalTo("id", id).findFirst()
// find the item Log.e("jingo", "查询数据 id= $id")
if (objects != null) {
oldBean = realm.copyFromRealm(objects)
oldBean?.let {
/**
* 获取当前所选的任务
*/
val objects = val objects =
bgRealm.where(QsRecordBean::class.java).equalTo("id", id).findFirst() realm.where(TaskBean::class.java).equalTo("id", it.taskId).findFirst()
if (objects != null) { if (objects != null) {
oldBean = bgRealm.copyFromRealm(objects) liveDataTaskBean.postValue(realm.copyFromRealm(objects))
oldBean?.let { }
liveDataQsRecordBean.postValue(it.copy())
val p = GeometryTools.createGeoPoint(it.geometry)
mapController.markerHandle.addMarker(
GeoPoint(
p.latitude,
p.longitude
), markerTitle,"",null
)
//获取linkid liveDataQsRecordBean.postValue(it.copy())
if (it.linkId.isNotEmpty()) { val p = GeometryTools.createGeoPoint(it.geometry)
viewModelScope.launch(Dispatchers.IO) { mapController.markerHandle.addMarker(
val link = realmOperateHelper.queryLink(it.linkId) GeoPoint(
link?.let { l -> p.latitude, p.longitude
mapController.lineHandler.showLine(l.geometry) ), TAG, "", null
} )
}
//获取linkid
if (it.linkId.isNotEmpty()) {
val link = realmOperateHelper.queryLink(it.linkId)
if (link != null) {
mapController.lineHandler.showLine(link.geometry)
} else {
val realmR = realm.where(HadLinkDvoBean::class.java)
.equalTo("linkPid", it.linkId).and().equalTo("taskId", it.taskId)
.findFirst()
if (realmR != null) {
mapController.lineHandler.showLine(realmR.geometry)
} }
liveDataQsRecordBean.value?.attachmentBeanList =
it.attachmentBeanList
// 显示语音数据到界面
getChatMsgEntityList()
} }
} }
liveDataQsRecordBean.value?.attachmentBeanList = it.attachmentBeanList
// 显示语音数据到界面
getChatMsgEntityList()
}
} else {
liveDataToastMessage.postValue("数据读取失败")
}
}
}
/**
* 查询问题类型列表
*/
private suspend fun getChatMsgEntityList() {
val chatMsgEntityList: MutableList<ChatMsgEntity> = ArrayList()
liveDataQsRecordBean.value?.attachmentBeanList?.forEach {
//1 录音
if (it.type == 1) {
val chatMsgEntity = ChatMsgEntity()
chatMsgEntity.name = it.name
chatMsgEntity.voiceUri = Constant.USER_DATA_ATTACHEMNT_PATH
chatMsgEntityList.add(chatMsgEntity)
}
}
listDataChatMsgEntityList.postValue(chatMsgEntityList)
}
fun addChatMsgEntity(filePath: String) {
if (filePath.isNotEmpty()) {
var chatMsgEntityList: MutableList<ChatMsgEntity> = ArrayList()
if (listDataChatMsgEntityList.value?.isEmpty() == false) {
chatMsgEntityList = listDataChatMsgEntityList.value!!
}
val chatMsgEntity = ChatMsgEntity()
chatMsgEntity.name = filePath.replace(Constant.USER_DATA_ATTACHEMNT_PATH, "").toString()
chatMsgEntity.voiceUri = Constant.USER_DATA_ATTACHEMNT_PATH
chatMsgEntityList.add(chatMsgEntity)
var attachmentList: RealmList<AttachmentBean> = RealmList()
//赋值处理
if (liveDataQsRecordBean.value?.attachmentBeanList?.isEmpty() == false) {
attachmentList = liveDataQsRecordBean.value?.attachmentBeanList!!
}
val attachmentBean = AttachmentBean()
attachmentBean.name = chatMsgEntity.name!!
attachmentBean.type = 1
attachmentList.add(attachmentBean)
liveDataQsRecordBean.value?.attachmentBeanList = attachmentList
listDataChatMsgEntityList.postValue(chatMsgEntityList)
}
}
fun startSoundMetter(activity: Activity, v: View) {
if (mSpeakMode == null) {
mSpeakMode = SpeakMode(activity)
}
//语音识别动画
if (pop == null) {
pop = PopupWindow()
pop!!.width = ViewGroup.LayoutParams.MATCH_PARENT
pop!!.height = ViewGroup.LayoutParams.WRAP_CONTENT
pop!!.setBackgroundDrawable(BitmapDrawable())
val view =
View.inflate(activity as Context, R.layout.cv_card_voice_rcd_hint_window, null)
pop!!.contentView = view
volume = view.findViewById(R.id.volume)
}
pop!!.update()
Constant.IS_VIDEO_SPEED = true
//录音动画
if (pop != null) {
pop!!.showAtLocation(v, Gravity.CENTER, 0, 0)
}
volume!!.setBackgroundResource(R.drawable.pop_voice_img)
val animation = volume!!.background as AnimationDrawable
animation.start()
val name: String = DateTimeUtil.getTimeSSS().toString() + ".m4a"
if (mSoundMeter == null) {
mSoundMeter = SoundMeter()
}
mSoundMeter!!.setmListener(object : SoundMeter.OnSoundMeterListener {
@RequiresApi(Build.VERSION_CODES.Q)
override fun onSuccess(filePath: String?) {
if (!TextUtils.isEmpty(filePath) && File(filePath).exists()) {
if (File(filePath) == null || File(filePath).length() < 1600) {
ToastUtils.showLong("语音时间太短,无效!")
mSpeakMode!!.speakText("语音时间太短,无效")
stopSoundMeter()
return
} }
} }
mSpeakMode!!.speakText("结束录音")
addChatMsgEntity(filePath!!)
} }
@RequiresApi(api = Build.VERSION_CODES.Q)
override fun onfaild(message: String?) {
ToastUtils.showLong("录制失败!")
mSpeakMode!!.speakText("录制失败")
stopSoundMeter()
}
})
mSoundMeter!!.start(Constant.USER_DATA_ATTACHEMNT_PATH + name)
ToastUtils.showLong("开始录音")
mSpeakMode!!.speakText("开始录音")
}
//停止语音录制
@RequiresApi(api = Build.VERSION_CODES.Q)
fun stopSoundMeter() {
//先重置标识,防止按钮抬起时触发语音结束
Constant.IS_VIDEO_SPEED = false
if (mSoundMeter != null && mSoundMeter!!.isStartSound) {
mSoundMeter!!.stop()
}
pop?.let {
if (it.isShowing) {
it.dismiss()
}
}
}
fun savePhoto(bitmap: Bitmap) {
viewModelScope.launch(Dispatchers.IO) {
// 创建一个名为 "MyApp" 的文件夹
val myAppDir = File(Constant.USER_DATA_ATTACHEMNT_PATH)
if (!myAppDir.exists()) myAppDir.mkdirs() // 确保文件夹已创建
// 创建一个名为 fileName 的文件
val file = File(myAppDir, "${UUID.randomUUID()}.png")
file.createNewFile() // 创建文件
// 将 Bitmap 压缩为 JPEG 格式,并将其写入文件中
val out = FileOutputStream(file)
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out)
out.flush()
out.close()
var picList = mutableListOf<String>()
if (liveDataPictureList.value == null) {
picList.add(file.absolutePath)
} else {
picList.addAll(liveDataPictureList.value!!)
picList.add(file.absolutePath)
}
liveDataPictureList.postValue(picList)
}
} }
/** /**
* 查询问题类型列表 * 监听任务选择变化
*/ */
fun getChatMsgEntityList() { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
val chatMsgEntityList: MutableList<ChatMsgEntity> = ArrayList() if (key == Constant.SELECT_TASK_ID && oldBean == null) {
liveDataQsRecordBean.value?.attachmentBeanList?.forEach { viewModelScope.launch(Dispatchers.IO) {
//1 录音 val taskId = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
if (it.type == 1) { val realm = Realm.getDefaultInstance()
val chatMsgEntity = ChatMsgEntity() val objects = realm.where(TaskBean::class.java).equalTo("id", taskId).findFirst()
chatMsgEntity.name = it.name if (objects != null) {
chatMsgEntity.voiceUri = Constant.USER_DATA_ATTACHEMNT_PATH liveDataTaskBean.postValue(realm.copyFromRealm(objects))
chatMsgEntityList.add(chatMsgEntity)
}
}
listDataChatMsgEntityList.postValue(chatMsgEntityList)
}
fun addChatMsgEntity(filePath: String) {
if (filePath.isNotEmpty()) {
var chatMsgEntityList: MutableList<ChatMsgEntity> = ArrayList()
if (listDataChatMsgEntityList.value?.isEmpty() == false) {
chatMsgEntityList = listDataChatMsgEntityList.value!!
}
val chatMsgEntity = ChatMsgEntity()
chatMsgEntity.name = filePath.replace(Constant.USER_DATA_ATTACHEMNT_PATH, "").toString()
chatMsgEntity.voiceUri = Constant.USER_DATA_ATTACHEMNT_PATH
chatMsgEntityList.add(chatMsgEntity)
var attachmentList: RealmList<AttachmentBean> = RealmList()
//赋值处理
if (liveDataQsRecordBean.value?.attachmentBeanList?.isEmpty() == false) {
attachmentList = liveDataQsRecordBean.value?.attachmentBeanList!!
}
val attachmentBean = AttachmentBean()
attachmentBean.name = chatMsgEntity.name!!
attachmentBean.type = 1
attachmentList.add(attachmentBean)
liveDataQsRecordBean.value?.attachmentBeanList = attachmentList
listDataChatMsgEntityList.postValue(chatMsgEntityList)
}
}
fun startSoundMetter(activity: Activity, v: View) {
if (mSpeakMode == null) {
mSpeakMode = SpeakMode(activity)
}
//语音识别动画
if (pop == null) {
pop = PopupWindow()
pop!!.width = ViewGroup.LayoutParams.MATCH_PARENT
pop!!.height = ViewGroup.LayoutParams.WRAP_CONTENT
pop!!.setBackgroundDrawable(BitmapDrawable())
val view =
View.inflate(activity as Context, R.layout.cv_card_voice_rcd_hint_window, null)
pop!!.contentView = view
volume = view.findViewById(R.id.volume)
}
pop!!.update()
Constant.IS_VIDEO_SPEED = true
//录音动画
if (pop != null) {
pop!!.showAtLocation(v, Gravity.CENTER, 0, 0)
}
volume!!.setBackgroundResource(R.drawable.pop_voice_img)
val animation = volume!!.background as AnimationDrawable
animation.start()
val name: String = DateTimeUtil.getTimeSSS().toString() + ".m4a"
if (mSoundMeter == null) {
mSoundMeter = SoundMeter()
}
mSoundMeter!!.setmListener(object : SoundMeter.OnSoundMeterListener {
@RequiresApi(Build.VERSION_CODES.Q)
override fun onSuccess(filePath: String?) {
if (!TextUtils.isEmpty(filePath) && File(filePath).exists()) {
if (File(filePath) == null || File(filePath).length() < 1600) {
ToastUtils.showLong("语音时间太短,无效!")
mSpeakMode!!.speakText("语音时间太短,无效")
stopSoundMeter()
return
}
} }
mSpeakMode!!.speakText("结束录音")
addChatMsgEntity(filePath!!)
}
@RequiresApi(api = Build.VERSION_CODES.Q)
override fun onfaild(message: String?) {
ToastUtils.showLong("录制失败!")
mSpeakMode!!.speakText("录制失败")
stopSoundMeter()
}
})
mSoundMeter!!.start(Constant.USER_DATA_ATTACHEMNT_PATH + name)
ToastUtils.showLong("开始录音")
mSpeakMode!!.speakText("开始录音")
}
//停止语音录制
@RequiresApi(api = Build.VERSION_CODES.Q)
fun stopSoundMeter() {
//先重置标识,防止按钮抬起时触发语音结束
Constant.IS_VIDEO_SPEED = false
if (mSoundMeter != null && mSoundMeter!!.isStartSound) {
mSoundMeter!!.stop()
}
pop?.let {
if (it.isShowing) {
it.dismiss()
} }
} }
} }
fun savePhoto(bitmap: Bitmap) {
viewModelScope.launch(Dispatchers.IO) {
// 创建一个名为 "MyApp" 的文件夹
val myAppDir = File(Constant.USER_DATA_ATTACHEMNT_PATH)
if (!myAppDir.exists())
myAppDir.mkdirs() // 确保文件夹已创建
// 创建一个名为 fileName 的文件
val file = File(myAppDir, "${UUID.randomUUID()}.png")
file.createNewFile() // 创建文件
// 将 Bitmap 压缩为 JPEG 格式,并将其写入文件中
val out = FileOutputStream(file)
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out)
out.flush()
out.close()
var picList = mutableListOf<String>()
if (liveDataPictureList.value == null) {
picList.add(file.absolutePath)
} else {
picList.addAll(liveDataPictureList.value!!)
picList.add(file.absolutePath)
}
liveDataPictureList.postValue(picList)
}
}
} }

View File

@ -246,7 +246,7 @@ class TaskLinkViewModel @Inject constructor(
/** /**
* 监听shared变化 * 监听shared变化
*/ */
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
if (key == Constant.SELECT_TASK_ID) { if (key == Constant.SELECT_TASK_ID) {
getTaskBean() getTaskBean()
} }
@ -313,32 +313,47 @@ class TaskLinkViewModel @Inject constructor(
* 删除数据 * 删除数据
*/ */
fun deleteData(context: Context) { fun deleteData(context: Context) {
if(hadLinkDvoBean == null){ if (hadLinkDvoBean == null) {
liveDataFinish.value = true liveDataFinish.value = true
return return
} }
val mDialog = FirstDialog(context) val mDialog = FirstDialog(context)
mDialog.setTitle("提示?") mDialog.setTitle("提示?")
mDialog.setMessage("是否删除Mark请确认") mDialog.setMessage("是否删除Mark请确认")
mDialog.setPositiveButton("确定" mDialog.setPositiveButton(
"确定"
) { _, _ -> ) { _, _ ->
mDialog.dismiss() mDialog.dismiss()
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
realm.executeTransaction { realm.executeTransaction {
val task = it.where(TaskBean::class.java).equalTo("id",hadLinkDvoBean!!.taskId).findFirst() //先找到对应的任务
if(task != null) { val task = it.where(TaskBean::class.java).equalTo("id", hadLinkDvoBean!!.taskId)
.findFirst()
//维护任务删除当前link
if (task != null) {
for (h in task.hadLinkDvoList) { for (h in task.hadLinkDvoList) {
if(h.linkPid == hadLinkDvoBean!!.linkPid) if (h.linkPid == hadLinkDvoBean!!.linkPid)
task.hadLinkDvoList.remove(h) task.hadLinkDvoList.remove(h)
break break
} }
realm.copyToRealmOrUpdate(task) realm.copyToRealmOrUpdate(task)
} }
// val objects = it.where(HadLinkDvoBean::class.java) //删除link
// .equalTo("linkPid", hadLinkDvoBean!!.linkPid).findFirst() val objects = it.where(HadLinkDvoBean::class.java)
// objects?.deleteFromRealm() .equalTo("linkPid", hadLinkDvoBean!!.linkPid).findFirst()
objects?.deleteFromRealm()
//删除相关联的评测任务
val qsRecordBeans = it.where(QsRecordBean::class.java)
.equalTo("linkId", hadLinkDvoBean!!.linkPid).and()
.equalTo("taskId", hadLinkDvoBean!!.taskId).findAll()
if (qsRecordBeans != null) {
for (b in qsRecordBeans) {
mapController.markerHandle.removeQsRecordMark(b)
}
qsRecordBeans.deleteAllFromRealm()
}
} }
mapController.lineHandler.removeTaskLink(hadLinkDvoBean!!.linkPid) mapController.lineHandler.removeTaskLink(hadLinkDvoBean!!.linkPid)
mapController.mMapView.vtmMap.updateMap(true) mapController.mMapView.vtmMap.updateMap(true)

View File

@ -17,8 +17,12 @@ import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.FragmentTaskBinding import com.navinfo.omqs.databinding.FragmentTaskBinding
import com.navinfo.omqs.ui.fragment.BaseFragment import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.other.shareViewModels import com.navinfo.omqs.ui.other.shareViewModels
import com.yanzhenjie.recyclerview.SwipeMenuBridge
import com.yanzhenjie.recyclerview.SwipeMenuCreator
import com.yanzhenjie.recyclerview.SwipeMenuItem
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.videolan.vlc.Util
/** /**
* 当前任务的道路列表 * 当前任务的道路列表
@ -36,12 +40,8 @@ class TaskFragment : BaseFragment() {
private val adapter: TaskAdapter by lazy { private val adapter: TaskAdapter by lazy {
TaskAdapter(object : TaskAdapterCallback { TaskAdapter(object : TaskAdapterCallback {
override fun itemOnClick(bean: HadLinkDvoBean) { override fun itemOnClick(bean: HadLinkDvoBean) {
if(bean!=null){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { viewModel.showCurrentLink(bean)
viewModel.showCurrentLink(bean)
}
}else{
Toast.makeText(context, "数据错误,无法显示!", Toast.LENGTH_SHORT).show()
} }
} }
@ -63,11 +63,43 @@ class TaskFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.taskAddLink.setOnClickListener {
viewModel.setSelectLink(!binding.taskAddLink.isSelected)
}
viewModel.liveDataSelectNewLink.observe(viewLifecycleOwner) {
binding.taskAddLink.isSelected = it
}
//注意:使用滑动菜单不能开启滑动删除,否则只有滑动删除没有滑动菜单
val mSwipeMenuCreator = SwipeMenuCreator { _, rightMenu, _ ->
//添加菜单自动添加至尾部
val deleteItem = SwipeMenuItem(context)
deleteItem.height = Util.convertDpToPx(requireContext(), 60)
deleteItem.width = Util.convertDpToPx(requireContext(), 80)
deleteItem.text = "删除"
deleteItem.background = requireContext().getDrawable(R.color.red)
deleteItem.setTextColor(requireContext().resources.getColor(R.color.white))
rightMenu.addMenuItem(deleteItem)
}
val layoutManager = LinearLayoutManager(context) val layoutManager = LinearLayoutManager(context)
//// 设置 RecyclerView 的固定大小,避免在滚动时重新计算视图大小和布局,提高性能 //// 设置 RecyclerView 的固定大小,避免在滚动时重新计算视图大小和布局,提高性能
binding.taskRecyclerview.setHasFixedSize(true) binding.taskRecyclerview.setHasFixedSize(true)
binding.taskRecyclerview.layoutManager = layoutManager binding.taskRecyclerview.layoutManager = layoutManager
//增加侧滑按钮
binding.taskRecyclerview.setSwipeMenuCreator(mSwipeMenuCreator)
//单项点击
binding.taskRecyclerview.setOnItemMenuClickListener { menuBridge, position ->
menuBridge.closeMenu()
viewModel.deleteTaskLink(requireContext(), adapter.data[position])
}
binding.taskRecyclerview.adapter = adapter binding.taskRecyclerview.adapter = adapter
binding.taskSearchClear.setOnClickListener { binding.taskSearchClear.setOnClickListener {
binding.taskSearch.setText("") binding.taskSearch.setText("")
} }
@ -90,6 +122,7 @@ class TaskFragment : BaseFragment() {
}) })
} }
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
_binding = null _binding = null

View File

@ -106,6 +106,8 @@ class TaskListFragment : BaseFragment() {
}) })
} }
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
_binding = null _binding = null

View File

@ -4,7 +4,9 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
import com.navinfo.omqs.databinding.FragmentTaskManagerBinding import com.navinfo.omqs.databinding.FragmentTaskManagerBinding
import com.navinfo.omqs.ui.fragment.BaseFragment import com.navinfo.omqs.ui.fragment.BaseFragment
@ -38,10 +40,20 @@ class TaskManagerFragment(private var backListener: ((TaskManagerFragment) -> Un
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
viewModel.liveDataToastMessage.observe(viewLifecycleOwner) {
Toast.makeText(requireContext(), it, Toast.LENGTH_SHORT).show()
}
//禁止滑动,因为页面在抽屉里,和抽屉的滑动有冲突 //禁止滑动,因为页面在抽屉里,和抽屉的滑动有冲突
binding.taskManagerViewpager.isUserInputEnabled = false binding.taskManagerViewpager.isUserInputEnabled = false
//创建viewpager2的适配器 //创建viewpager2的适配器
binding.taskManagerViewpager.adapter = activity?.let { TaskManagerAdapter(it) } binding.taskManagerViewpager.adapter = activity?.let { TaskManagerAdapter(it) }
binding.taskManagerViewpager.registerOnPageChangeCallback(object :
ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
viewModel.setSelectLink(false)
}
})
//绑定viewpager2与tabLayout //绑定viewpager2与tabLayout
TabLayoutMediator( TabLayoutMediator(
binding.taskManagerTabLayout, binding.taskManagerTabLayout,

View File

@ -1,12 +1,11 @@
package com.navinfo.omqs.ui.fragment.tasklist package com.navinfo.omqs.ui.fragment.tasklist
import android.app.Dialog
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.os.Build import android.os.Build
import android.view.View
import android.widget.Toast import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
@ -16,8 +15,10 @@ import com.navinfo.collect.library.data.entity.NiLocation
import com.navinfo.collect.library.data.entity.QsRecordBean import com.navinfo.collect.library.data.entity.QsRecordBean
import com.navinfo.collect.library.data.entity.TaskBean import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.collect.library.map.NIMapController import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.map.OnGeoPointClickListener
import com.navinfo.collect.library.utils.GeometryTools import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.omqs.Constant import com.navinfo.omqs.Constant
import com.navinfo.omqs.db.RealmOperateHelper
import com.navinfo.omqs.http.NetResult import com.navinfo.omqs.http.NetResult
import com.navinfo.omqs.http.NetworkService import com.navinfo.omqs.http.NetworkService
import com.navinfo.omqs.tools.FileManager import com.navinfo.omqs.tools.FileManager
@ -26,6 +27,8 @@ import com.navinfo.omqs.util.DateTimeUtil
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import io.realm.Realm import io.realm.Realm
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.flow.collectLatest
import org.oscim.core.GeoPoint
import javax.inject.Inject import javax.inject.Inject
@ -33,8 +36,10 @@ import javax.inject.Inject
class TaskViewModel @Inject constructor( class TaskViewModel @Inject constructor(
private val networkService: NetworkService, private val networkService: NetworkService,
private val mapController: NIMapController, private val mapController: NIMapController,
private val sharedPreferences: SharedPreferences private val sharedPreferences: SharedPreferences,
private val realmOperateHelper: RealmOperateHelper,
) : ViewModel(), OnSharedPreferenceChangeListener { ) : ViewModel(), OnSharedPreferenceChangeListener {
private val TAG = "TaskViewModel"
/** /**
* 用来更新任务列表 * 用来更新任务列表
@ -58,6 +63,11 @@ class TaskViewModel @Inject constructor(
*/ */
val liveDataCloseTask = MutableLiveData<Boolean>() val liveDataCloseTask = MutableLiveData<Boolean>()
/**
* 提示信息
*/
val liveDataToastMessage = MutableLiveData<String>()
/** /**
* 当前选中的任务 * 当前选中的任务
*/ */
@ -70,6 +80,10 @@ class TaskViewModel @Inject constructor(
private var filterTaskJob: Job? = null private var filterTaskJob: Job? = null
/**
* 是否开启了道路选择
*/
var liveDataSelectNewLink = MutableLiveData(false)
init { init {
sharedPreferences.registerOnSharedPreferenceChangeListener(this) sharedPreferences.registerOnSharedPreferenceChangeListener(this)
@ -318,65 +332,13 @@ class TaskViewModel @Inject constructor(
* 关闭任务 * 关闭任务
*/ */
fun removeTask(context: Context, taskBean: TaskBean) { fun removeTask(context: Context, taskBean: TaskBean) {
if (taskBean != null) {
val mDialog = FirstDialog(context)
mDialog.setTitle("提示?")
mDialog.setMessage("是否关闭,请确认!")
mDialog.setPositiveButton("确定", object : FirstDialog.OnClickListener {
override fun onClick(dialog: Dialog?, which: Int) {
mDialog.dismiss()
viewModelScope.launch(Dispatchers.IO) {
val realm = Realm.getDefaultInstance()
realm.executeTransaction {
val objects = it.where(TaskBean::class.java)
.equalTo("id", taskBean.id).findFirst()
objects?.deleteFromRealm()
}
//遍历删除对应的数据
taskBean.hadLinkDvoList.forEach { hadLinkDvoBean ->
val qsRecordList = realm.where(QsRecordBean::class.java)
.equalTo("linkId", hadLinkDvoBean.linkPid).findAll()
if (qsRecordList != null && qsRecordList.size > 0) {
val copyList = realm.copyFromRealm(qsRecordList)
copyList.forEach {
it.deleteFromRealm()
mapController.markerHandle.removeQsRecordMark(it)
mapController.mMapView.vtmMap.updateMap(true)
}
}
}
//过滤掉已上传的超过90天的数据
var nowTime: Long = DateTimeUtil.getNowDate().time
var beginNowTime: Long = nowTime - 90 * 3600 * 24 * 1000L
var syncUpload: Int = FileManager.Companion.FileUploadStatus.DONE
val objects = realm.where(TaskBean::class.java)
.notEqualTo("syncStatus", syncUpload).or()
.between("operationTime", beginNowTime, nowTime)
.equalTo("syncStatus", syncUpload).findAll()
val taskList = realm.copyFromRealm(objects)
for (item in taskList) {
FileManager.checkOMDBFileInfo(item)
}
liveDataTaskList.postValue(taskList)
liveDataCloseTask.postValue(true)
}
}
})
mDialog.setNegativeButton("取消", object : FirstDialog.OnClickListener {
override fun onClick(dialog: Dialog?, which: Int) {
liveDataCloseTask.postValue(false)
mDialog.dismiss()
}
})
mDialog.show()
}
val mDialog = FirstDialog(context) val mDialog = FirstDialog(context)
mDialog.setTitle("提示?") mDialog.setTitle("提示?")
mDialog.setMessage("是否关闭,请确认!") mDialog.setMessage("是否关闭,请确认!")
mDialog.setPositiveButton( mDialog.setPositiveButton(
"确定" "确定"
) { _, _ -> ) { dialog, _ ->
mDialog.dismiss() dialog.dismiss()
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
realm.executeTransaction { realm.executeTransaction {
@ -387,7 +349,8 @@ class TaskViewModel @Inject constructor(
//遍历删除对应的数据 //遍历删除对应的数据
taskBean.hadLinkDvoList.forEach { hadLinkDvoBean -> taskBean.hadLinkDvoList.forEach { hadLinkDvoBean ->
val qsRecordList = realm.where(QsRecordBean::class.java) val qsRecordList = realm.where(QsRecordBean::class.java)
.equalTo("linkId", hadLinkDvoBean.linkPid).findAll() .equalTo("linkId", hadLinkDvoBean.linkPid).and()
.equalTo("taskId", hadLinkDvoBean.taskId).findAll()
if (qsRecordList != null && qsRecordList.size > 0) { if (qsRecordList != null && qsRecordList.size > 0) {
val copyList = realm.copyFromRealm(qsRecordList) val copyList = realm.copyFromRealm(qsRecordList)
copyList.forEach { copyList.forEach {
@ -410,9 +373,15 @@ class TaskViewModel @Inject constructor(
FileManager.checkOMDBFileInfo(item) FileManager.checkOMDBFileInfo(item)
} }
liveDataTaskList.postValue(taskList) liveDataTaskList.postValue(taskList)
liveDataCloseTask.postValue(true)
} }
} }
mDialog.setNegativeButton("取消", null) mDialog.setNegativeButton(
"取消"
) { _, _ ->
liveDataCloseTask.postValue(false)
mDialog.dismiss()
}
mDialog.show() mDialog.show()
} }
@ -421,7 +390,8 @@ class TaskViewModel @Inject constructor(
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
taskBean.hadLinkDvoList.forEach { hadLinkDvoBean -> taskBean.hadLinkDvoList.forEach { hadLinkDvoBean ->
val objects = realm.where(QsRecordBean::class.java) val objects = realm.where(QsRecordBean::class.java)
.equalTo("linkId", hadLinkDvoBean.linkPid).findAll() .equalTo("linkId", hadLinkDvoBean.linkPid).and()
.equalTo("taskId", hadLinkDvoBean.taskId).findAll()
val map: MutableMap<TaskBean, Boolean> = HashMap<TaskBean, Boolean>() val map: MutableMap<TaskBean, Boolean> = HashMap<TaskBean, Boolean>()
if (objects.isEmpty() && hadLinkDvoBean.reason.isEmpty()) { if (objects.isEmpty() && hadLinkDvoBean.reason.isEmpty()) {
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
@ -452,11 +422,127 @@ class TaskViewModel @Inject constructor(
/** /**
* 监听新增的评测link * 监听新增的评测link
*/ */
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
if (key == Constant.SHARED_SYNC_TASK_LINK_ID) { if (key == Constant.SHARED_SYNC_TASK_LINK_ID) {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
getLocalTaskList() getLocalTaskList()
} }
} }
} }
/**
* 设置是否开启选择link
*/
fun setSelectLink(selected: Boolean) {
liveDataSelectNewLink.value = selected
//开始捕捉
if (selected) {
mapController.mMapView.addOnNIMapClickListener(TAG, object : OnGeoPointClickListener {
override fun onMapClick(tag: String, point: GeoPoint) {
if (tag == TAG) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
viewModelScope.launch(Dispatchers.Default) {
if (currentSelectTaskBean == null) {
liveDataToastMessage.postValue("还没有开启任何任务")
} else {
val links = realmOperateHelper.queryLink(
point = point,
)
if (links.isNotEmpty()) {
val l = links[0]
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
if (link.linkPid == l.properties["linkPid"]) {
return@launch
}
}
val hadLinkDvoBean = HadLinkDvoBean(
taskId = currentSelectTaskBean!!.id,
linkPid = l.properties["linkPid"]!!,
geometry = l.geometry,
linkStatus = 2
)
currentSelectTaskBean!!.hadLinkDvoList.add(
hadLinkDvoBean
)
val realm = Realm.getDefaultInstance()
realm.executeTransaction { r ->
r.copyToRealmOrUpdate(hadLinkDvoBean)
r.copyToRealmOrUpdate(currentSelectTaskBean!!)
}
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
mapController.lineHandler.addTaskLink(hadLinkDvoBean)
}
}
}
}
}
}
})
} else {
mapController.mMapView.removeOnNIMapClickListener(TAG)
mapController.lineHandler.removeLine()
}
}
/**
* 删除评测link
*/
fun deleteTaskLink(context: Context, hadLinkDvoBean: HadLinkDvoBean) {
if (hadLinkDvoBean.linkStatus == 1) {
val mDialog = FirstDialog(context)
mDialog.setTitle("提示")
mDialog.setMessage("当前要评测的link是任务原始规划的不能删除如果不进行作业请标记原因")
mDialog.setCancelVisibility(View.GONE)
mDialog.setPositiveButton(
"确定"
) { _, _ ->
mDialog.dismiss()
}
mDialog.show()
} else {
val mDialog = FirstDialog(context)
mDialog.setTitle("提示")
mDialog.setMessage("是否删除当前link与之相关联的评测任务会一起删除")
mDialog.setPositiveButton(
"确定"
) { dialog, _ ->
dialog.dismiss()
viewModelScope.launch(Dispatchers.IO) {
val realm = Realm.getDefaultInstance()
realm.executeTransaction {
for (link in currentSelectTaskBean!!.hadLinkDvoList) {
if (link.linkPid == hadLinkDvoBean.linkPid) {
currentSelectTaskBean!!.hadLinkDvoList.remove(link)
break
}
}
realm.where(HadLinkDvoBean::class.java)
.equalTo("linkPid", hadLinkDvoBean.linkPid).findFirst()
?.deleteFromRealm()
val markers = realm.where(QsRecordBean::class.java)
.equalTo("linkId", hadLinkDvoBean.linkPid)
.and().equalTo("taskId", hadLinkDvoBean.taskId)
.findAll()
if(markers != null){
for(marker in markers){
mapController.markerHandle.removeQsRecordMark(marker)
}
markers.deleteAllFromRealm()
}
realm.copyToRealmOrUpdate(currentSelectTaskBean)
mapController.lineHandler.removeTaskLink(hadLinkDvoBean.linkPid)
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
}
}
}
mDialog.setNegativeButton(
"取消"
) { _, _ ->
mDialog.dismiss()
}
mDialog.show()
}
}
} }

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#91909A"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#1717E0"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/baseline_add_24_press" android:state_selected="true" />
<item android:drawable="@drawable/baseline_add_24" android:state_selected="false" />
</selector>

View File

@ -87,6 +87,24 @@
android:layout_marginBottom="7dp" android:layout_marginBottom="7dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="7dp"
android:orientation="horizontal">
<TextView
style="@style/evaluation_fragment_title_text_style"
android:text="任务名称" />
<TextView
android:id="@+id/evaluation_task_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{viewModel.liveDataTaskBean.evaluationTaskName}" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -8,7 +8,7 @@
<EditText <EditText
android:id="@+id/task_search" android:id="@+id/task_search"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
@ -20,8 +20,19 @@
android:singleLine="true" android:singleLine="true"
android:textSize="13sp" android:textSize="13sp"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/task_add_link"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/task_add_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:src="@drawable/selector_add_taskline"
app:layout_constraintBottom_toBottomOf="@id/task_search"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/task_search" />
<ImageView <ImageView
android:layout_width="14dp" android:layout_width="14dp"
android:layout_height="14dp" android:layout_height="14dp"
@ -41,7 +52,7 @@
app:layout_constraintRight_toRightOf="@id/task_search" app:layout_constraintRight_toRightOf="@id/task_search"
app:layout_constraintTop_toTopOf="@id/task_search" /> app:layout_constraintTop_toTopOf="@id/task_search" />
<androidx.recyclerview.widget.RecyclerView <com.yanzhenjie.recyclerview.SwipeRecyclerView
android:id="@+id/task_recyclerview" android:id="@+id/task_recyclerview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"

View File

@ -15,6 +15,7 @@ import io.realm.annotations.PrimaryKey
*/ */
//@RealmClass //@RealmClass
open class QsRecordBean @JvmOverloads constructor( open class QsRecordBean @JvmOverloads constructor(
var taskId: Int = -1,
/** /**
* id 主键 * id 主键
* *
@ -97,6 +98,7 @@ open class QsRecordBean @JvmOverloads constructor(
fun copy(): QsRecordBean { fun copy(): QsRecordBean {
val qs = QsRecordBean( val qs = QsRecordBean(
taskId = taskId,
id = id, id = id,
elementId = elementId, elementId = elementId,
linkId = linkId, linkId = linkId,

View File

@ -0,0 +1,3 @@
package com.navinfo.collect.library.map
interface BaseClickListener

View File

@ -1,12 +1,8 @@
package com.navinfo.collect.library.map package com.navinfo.collect.library.map
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.navinfo.collect.library.map.handler.* import com.navinfo.collect.library.map.handler.*
import com.navinfo.collect.library.system.Constant import com.navinfo.collect.library.system.Constant
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch
import org.oscim.core.GeoPoint
/** /**
* 地图控制器 * 地图控制器
@ -23,7 +19,7 @@ class NIMapController {
lateinit var viewportHandler: ViewportHandler lateinit var viewportHandler: ViewportHandler
lateinit var measureLayerHandler: MeasureLayerHandler lateinit var measureLayerHandler: MeasureLayerHandler
val onMapClickFlow = MutableSharedFlow<GeoPoint>() // val onMapClickFlow = MutableSharedFlow<GeoPoint>()
fun init( fun init(
context: AppCompatActivity, context: AppCompatActivity,
@ -43,13 +39,26 @@ class NIMapController {
measureLayerHandler = MeasureLayerHandler(context, mapView) measureLayerHandler = MeasureLayerHandler(context, mapView)
mMapView = mapView mMapView = mapView
mMapView.setOnMapClickListener { mMapView.setOnMapClickListener {
context.lifecycleScope.launch { if (mapView.listenerTagList.isNotEmpty()) {
onMapClickFlow.emit(it) val tag = mapView.listenerTagList.last()
val listenerList = mapView.listenerList[tag]
if (listenerList != null) {
for (listener in listenerList) {
if (listener is OnGeoPointClickListener) {
listener.onMapClick(tag, it)
return@setOnMapClickListener
}
}
}
} }
// context.lifecycleScope.launch {
// onMapClickFlow.emit(it)
// }
} }
mapView.setOptions(options) mapView.setOptions(options)
} }
} }

View File

@ -3,8 +3,8 @@ package com.navinfo.collect.library.map;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -12,12 +12,12 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.navinfo.collect.library.R; import com.navinfo.collect.library.R;
import com.navinfo.collect.library.data.entity.NiLocation; import com.navinfo.collect.library.data.entity.NiLocation;
import com.navinfo.collect.library.map.layers.NaviMapScaleBar; import com.navinfo.collect.library.map.layers.NaviMapScaleBar;
import com.navinfo.collect.library.map.source.MapLifeNiLocationTileSource;
import org.oscim.android.MapPreferences; import org.oscim.android.MapPreferences;
import org.oscim.android.MapView; import org.oscim.android.MapView;
@ -29,22 +29,14 @@ import org.oscim.event.Gesture;
import org.oscim.event.GestureListener; import org.oscim.event.GestureListener;
import org.oscim.layers.GroupLayer; import org.oscim.layers.GroupLayer;
import org.oscim.layers.Layer; import org.oscim.layers.Layer;
import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.OsmTileLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.layers.tile.vector.labeling.LabelTileLoaderHook;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.renderer.GLViewport; import org.oscim.renderer.GLViewport;
import org.oscim.scalebar.MapScaleBarLayer; import org.oscim.scalebar.MapScaleBarLayer;
import org.oscim.theme.IRenderTheme;
import org.oscim.theme.ThemeLoader;
import org.oscim.theme.VtmThemes; import org.oscim.theme.VtmThemes;
import org.oscim.tiling.source.mapfile.MapFileTileSource;
import org.oscim.tiling.source.mapfile.MultiMapFileTileSource;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
@ -91,11 +83,6 @@ public final class NIMapView extends RelativeLayout {
* 地图状态设置 * 地图状态设置
*/ */
private NIMapOptions options; private NIMapOptions options;
/**
* 地图图层管理器
*/
// private NILayerManager mLayerManager;
// private Layer baseRasterLayer, defaultVectorTileLayer, defaultVectorLabelLayer, gridLayer;
/** /**
* 地图网格图层 * 地图网格图层
*/ */
@ -109,6 +96,23 @@ public final class NIMapView extends RelativeLayout {
protected String mapFilePath = "/map"; protected String mapFilePath = "/map";
protected GroupLayer baseGroupLayer; // 用于盛放所有基础底图的图层组便于统一管理 protected GroupLayer baseGroupLayer; // 用于盛放所有基础底图的图层组便于统一管理
private HashMap<String, BaseClickListener[]> listenerList = new HashMap();
private List<String> listenerTagList = new ArrayList();
public HashMap<String, BaseClickListener[]> getListenerList() {
return listenerList;
}
/**
* 获取所有tag
*
* @return
*/
public List<String> getListenerTagList() {
return listenerTagList;
}
public void setOptions(NIMapOptions option) { public void setOptions(NIMapOptions option) {
this.options = option; this.options = option;
initOptions(); initOptions();
@ -812,8 +816,6 @@ public final class NIMapView extends RelativeLayout {
/** /**
* 设置logo显隐 * 设置logo显隐
*
* @param position 按钮位置
*/ */
public void setLogoVisable(int visable) { public void setLogoVisable(int visable) {
if (logoImage != null) { if (logoImage != null) {
@ -886,12 +888,13 @@ public final class NIMapView extends RelativeLayout {
/** /**
* 设置比例尺位置 * 设置比例尺位置
*
* @param position * @param position
* @param xOffset * @param xOffset
* @param yOffset * @param yOffset
*/ */
public void setScaleBarLayer(GLViewport.Position position, int xOffset, int yOffset){ public void setScaleBarLayer(GLViewport.Position position, int xOffset, int yOffset) {
if(mapScaleBarLayer!=null&&mapView.map().layers().contains(mapScaleBarLayer)){ if (mapScaleBarLayer != null && mapView.map().layers().contains(mapScaleBarLayer)) {
mapView.map().layers().remove(mapScaleBarLayer); mapView.map().layers().remove(mapScaleBarLayer);
mapScaleBarLayer = null; mapScaleBarLayer = null;
} }
@ -1029,4 +1032,39 @@ public final class NIMapView extends RelativeLayout {
mapView.map().updateMap(redraw); mapView.map().updateMap(redraw);
} }
/**
* 增加地图点击监听
*/
public boolean addOnNIMapClickListener(@NonNull String tag, @NonNull BaseClickListener... listeners) {
if (TextUtils.equals(tag, "")) {
return false;
}
for (Object s : listenerTagList) {
if (s == tag) {
return false;
}
}
listenerTagList.add(tag);
listenerList.put(tag, listeners);
return true;
}
/**
* 移除点击监听
*
* @param tag
*/
public void removeOnNIMapClickListener(@NonNull String tag) {
listenerList.remove(tag);
for (String t : listenerTagList) {
if (t.equals(tag)) {
listenerTagList.remove(t);
return;
}
}
}
} }

View File

@ -0,0 +1,7 @@
package com.navinfo.collect.library.map
import org.oscim.core.GeoPoint
interface OnGeoPointClickListener : BaseClickListener {
fun onMapClick(tag: String, point: GeoPoint)
}

View File

@ -4,6 +4,7 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.navinfo.collect.library.R import com.navinfo.collect.library.R
import com.navinfo.collect.library.data.entity.HadLinkDvoBean import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.collect.library.map.BaseClickListener
import com.navinfo.collect.library.map.NIMapView import com.navinfo.collect.library.map.NIMapView
import com.navinfo.collect.library.map.layers.MultiLinesLayer import com.navinfo.collect.library.map.layers.MultiLinesLayer
import com.navinfo.collect.library.map.layers.OmdbTaskLinkLayer import com.navinfo.collect.library.map.layers.OmdbTaskLinkLayer
@ -19,21 +20,23 @@ import org.oscim.layers.vector.geometries.Style
class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(context, mapView) { class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(context, mapView) {
//绘制线 样式
private val lineStyle: Style
//高亮线绘制线 样式
private val defaultLineStyle: Style
/** /**
* 高亮线图层同时只高亮一条线如线选择 * 高亮线图层同时只高亮一条线如线选择
*/ */
private val mDefaultPathLayer: PathLayer private val mDefaultPathLayer: PathLayer by lazy {
//高亮线绘制线 样式
val defaultLineStyle = Style.builder()
.stippleColor(context.resources.getColor(R.color.draw_line_blue2_color))
.strokeWidth(10f)
.fillColor(context.resources.getColor(R.color.teal_200))
.fillAlpha(0.5f)
.strokeColor(context.resources.getColor(R.color.teal_200))
.fixed(true).build()
private var onTaskLinkItemClickListener: OnTaskLinkItemClickListener? = null val layer = PathLayer(mMapView.vtmMap, defaultLineStyle)
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_LINE)
fun setOnTaskLinkItemClickListener(listener: OnTaskLinkItemClickListener) { layer
onTaskLinkItemClickListener = listener
} }
@ -84,12 +87,18 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
markerSymbol, markerSymbol,
object : OnItemGestureListener<MarkerInterface> { object : OnItemGestureListener<MarkerInterface> {
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean { override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
onTaskLinkItemClickListener?.let { val tag = mMapView.listenerTagList.last()
if (item is MarkerItem) { val listenerList = mMapView.listenerList[tag]
it.onTaskLink(item.title) if (listenerList != null) {
for (listener in listenerList) {
if (listener is OnTaskLinkItemClickListener) {
if (item is MarkerItem) {
listener.onTaskLink(tag, item.title)
}
break
}
} }
} }
return false return false
} }
@ -103,30 +112,6 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
layer layer
} }
init {
//新增线数据图层和线样式
lineStyle = Style.builder()
.stippleColor(context.resources.getColor(R.color.draw_line_blue1_color))
.strokeWidth(4f)
.fillColor(context.resources.getColor(R.color.draw_line_blue2_color))
.fillAlpha(0.5f)
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color))
.fixed(true).build()
defaultLineStyle = Style.builder()
.stippleColor(context.resources.getColor(R.color.draw_line_blue2_color))
.strokeWidth(10f)
.fillColor(context.resources.getColor(R.color.teal_200))
.fillAlpha(0.5f)
.strokeColor(context.resources.getColor(R.color.teal_200))
.fixed(true).build()
mDefaultPathLayer = PathLayer(mMapView.vtmMap, defaultLineStyle)
addLayer(mDefaultPathLayer, NIMapView.LAYER_GROUPS.OPERATE_LINE)
}
/** /**
* 高亮一条线 * 高亮一条线
@ -226,6 +211,6 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
} }
} }
interface OnTaskLinkItemClickListener { interface OnTaskLinkItemClickListener : BaseClickListener {
fun onTaskLink(taskLinkId: String) fun onTaskLink(tag: String, taskLinkId: String)
} }

View File

@ -10,6 +10,7 @@ import com.navinfo.collect.library.R
import com.navinfo.collect.library.data.entity.NiLocation import com.navinfo.collect.library.data.entity.NiLocation
import com.navinfo.collect.library.data.entity.NoteBean import com.navinfo.collect.library.data.entity.NoteBean
import com.navinfo.collect.library.data.entity.QsRecordBean import com.navinfo.collect.library.data.entity.QsRecordBean
import com.navinfo.collect.library.map.BaseClickListener
import com.navinfo.collect.library.map.NIMapView import com.navinfo.collect.library.map.NIMapView
import com.navinfo.collect.library.map.cluster.ClusterMarkerItem import com.navinfo.collect.library.map.cluster.ClusterMarkerItem
import com.navinfo.collect.library.map.cluster.ClusterMarkerRenderer import com.navinfo.collect.library.map.cluster.ClusterMarkerRenderer
@ -144,18 +145,22 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
list: MutableList<Int>, list: MutableList<Int>,
nearest: Int nearest: Int
): Boolean { ): Boolean {
itemListener?.let { val tag = mMapView.listenerTagList.last()
val idList = mutableListOf<String>() val listenerList = mMapView.listenerList[tag]
if (list.size == 0) { if (listenerList != null) {
} else { for (listener in listenerList) {
for (i in list) { if (listener is OnQsRecordItemClickListener) {
val markerInterface: MarkerInterface = val idList = mutableListOf<String>()
qsRecordItemizedLayer.itemList[i] for (i in list) {
if (markerInterface is MarkerItem) { val markerInterface: MarkerInterface =
idList.add(markerInterface.title) qsRecordItemizedLayer.itemList[i]
if (markerInterface is MarkerItem) {
idList.add(markerInterface.title)
}
} }
listener.onQsRecordList(tag, idList.distinct().toMutableList())
break
} }
it.onQsRecordList(idList.distinct().toMutableList())
} }
} }
return true return true
@ -184,17 +189,28 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
) )
layer.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> { layer.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> {
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean { override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
itemListener?.let { val tag = mMapView.listenerTagList.last()
it.onNiLocation(index,(niLocationItemizedLayer.itemList[index] as MarkerItem).uid as NiLocation) val listenerList = mMapView.listenerList[tag]
if (listenerList != null) {
for (listener in listenerList) {
if (listener is OnNiLocationItemListener) {
listener.onNiLocation(
tag,
index,
(niLocationItemizedLayer.itemList[index] as MarkerItem).uid as NiLocation
)
break
}
}
} }
return true return true
} }
override fun onItemLongPress(index: Int, item: MarkerInterface?): Boolean { override fun onItemLongPress(index: Int, item: MarkerInterface?): Boolean {
return true return true
} }
}) })
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_MARKER) addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
layer layer
@ -222,10 +238,17 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
) )
layer.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> { layer.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> {
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean { override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
itemListener?.let { val tag = mMapView.listenerTagList.last()
val marker = layer.itemList[index] val listenerList = mMapView.listenerList[tag]
if (marker is MarkerItem) if (listenerList != null) {
it.onNote(marker.title) for (listener in listenerList) {
if (listener is ONNoteItemClickListener) {
val marker = layer.itemList[index]
if (marker is MarkerItem)
listener.onNote(tag, marker.title)
break
}
}
} }
return true return true
} }
@ -241,7 +264,6 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
private val resId = R.mipmap.map_icon_report private val resId = R.mipmap.map_icon_report
private val noteResId = R.drawable.icon_note_marker private val noteResId = R.drawable.icon_note_marker
private var itemListener: OnQsRecordItemClickListener? = null
/** /**
* 文字大小 * 文字大小
@ -259,22 +281,15 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
}) })
} }
/**
* 设置marker 点击回调
*/
fun setOnQsRecordItemClickListener(listener: OnQsRecordItemClickListener?) {
itemListener = listener
}
/** /**
* 增加marker * 增加marker
*/ */
fun addMarker( fun addMarker(
geoPoint: GeoPoint, geoPoint: GeoPoint,
title: String?, title: String?,
description: String? = "", description: String? = "",
uid: java.lang.Object?=null, uid: java.lang.Object? = null,
) { ) {
var marker: MarkerItem? = null var marker: MarkerItem? = null
for (e in mDefaultMarkerLayer.itemList) { for (e in mDefaultMarkerLayer.itemList) {
@ -307,8 +322,8 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
fun getCurrentMark(): MarkerInterface? { fun getCurrentMark(): MarkerInterface? {
if(mDefaultMarkerLayer!=null){ if (mDefaultMarkerLayer != null) {
return mDefaultMarkerLayer.itemList[mDefaultMarkerLayer.itemList.size-1] return mDefaultMarkerLayer.itemList[mDefaultMarkerLayer.itemList.size - 1]
} }
return null return null
} }
@ -488,7 +503,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
} }
} }
private fun createNILocationBitmap(niLocation: NiLocation): MarkerItem{ private fun createNILocationBitmap(niLocation: NiLocation): MarkerItem {
val direction: Double = niLocation.direction val direction: Double = niLocation.direction
@ -754,31 +769,39 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
niLocationItemizedLayer.update() niLocationItemizedLayer.update()
} }
fun getNILocationItemizedLayerSize():Int{ /**
* 移除所有质检数据
*/
fun removeAllQsMarker() {
qsRecordItemizedLayer.removeAllItems()
mMapView.updateMap(true)
}
fun getNILocationItemizedLayerSize(): Int {
return niLocationItemizedLayer.itemList.size return niLocationItemizedLayer.itemList.size
} }
fun getNILocation(index:Int):NiLocation?{ fun getNILocation(index: Int): NiLocation? {
return if(index>-1&&index<getNILocationItemizedLayerSize()){ return if (index > -1 && index < getNILocationItemizedLayerSize()) {
((niLocationItemizedLayer.itemList[index])as MarkerItem).uid as NiLocation ((niLocationItemizedLayer.itemList[index]) as MarkerItem).uid as NiLocation
}else{ } else {
null null
} }
} }
fun getNILocationIndex(niLocation: NiLocation):Int?{ fun getNILocationIndex(niLocation: NiLocation): Int? {
var list = niLocationItemizedLayer.itemList var list = niLocationItemizedLayer.itemList
if(niLocation!=null&&list.isNotEmpty()){ if (niLocation != null && list.isNotEmpty()) {
var index = -1 var index = -1
list.forEach{ list.forEach {
index += 1 index += 1
if(((it as MarkerItem).uid as NiLocation).id.equals(niLocation.id)){ if (((it as MarkerItem).uid as NiLocation).id.equals(niLocation.id)) {
return index return index
} }
} }
@ -786,11 +809,16 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
return -1 return -1
} }
} }
interface OnQsRecordItemClickListener { interface OnQsRecordItemClickListener : BaseClickListener {
fun onQsRecordList(list: MutableList<String>) fun onQsRecordList(tag: String, list: MutableList<String>)
fun onNote(noteId: String) }
fun onNiLocation(index:Int,it: NiLocation)
interface ONNoteItemClickListener : BaseClickListener {
fun onNote(tag: String, noteId: String)
}
interface OnNiLocationItemListener : BaseClickListener {
fun onNiLocation(tag: String, index: Int, it: NiLocation)
} }

2
vtm

@ -1 +1 @@
Subproject commit dd13e533c38b5738ab404c2737d7ccadeff01323 Subproject commit 1ee201a41f78f169873848209a3f3bdac36f185a