修改定位,修改提前看板
This commit is contained in:
@@ -79,16 +79,14 @@ class RealmOperateHelper() {
|
||||
}
|
||||
|
||||
|
||||
suspend fun queryLink(
|
||||
linkPid: String,
|
||||
): RenderEntity? {
|
||||
suspend fun queryLink(linkPid: String): RenderEntity? {
|
||||
var link: RenderEntity? = null
|
||||
withContext(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val realmR = realm.where(RenderEntity::class.java)
|
||||
.equalTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.rawPredicate("properties['${LinkTable.linkPid}']=$linkPid")
|
||||
.equalTo("properties['${LinkTable.linkPid}']", linkPid)
|
||||
.findFirst()
|
||||
if (realmR != null) {
|
||||
link = realm.copyFromRealm(realmR)
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.room.Room
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.OMQSApplication
|
||||
import com.navinfo.omqs.db.RoomAppDatabase
|
||||
@@ -90,7 +91,7 @@ class GlobalModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideGson(): Gson = GsonBuilder()
|
||||
// 解决解析Json时将int类型自动转换为Double的问题
|
||||
// 解决解析Json时将int类型自动转换为Double的问题
|
||||
.registerTypeAdapter(object : TypeToken<Map<String, Any?>>() {}.getType(), IntTypeAdapter())
|
||||
.registerTypeAdapter(object : TypeToken<Map<String, Any>>() {}.getType(), IntTypeAdapter())
|
||||
.registerTypeAdapter(object : TypeToken<Map<Any, Any>>() {}.getType(), IntTypeAdapter())
|
||||
@@ -137,6 +138,15 @@ class GlobalModule {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideTraceDatabase(context: Application): TraceDataBase {
|
||||
return TraceDataBase.getDatabase(
|
||||
context,
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
)
|
||||
}
|
||||
|
||||
// /**
|
||||
// * realm 注册
|
||||
// */
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.activity.viewModels
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.NiLocationListener
|
||||
@@ -32,6 +35,7 @@ class MainActivity : BaseActivity() {
|
||||
@Inject
|
||||
lateinit var offlineMapDownloadManager: OfflineMapDownloadManager
|
||||
|
||||
private val signAdapter by lazy { SignAdapter() }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
@@ -43,7 +47,7 @@ class MainActivity : BaseActivity() {
|
||||
binding.mainActivityMap,
|
||||
null,
|
||||
Constant.MAP_PATH,
|
||||
Constant.USER_DATA_PATH+"/trace.sqlite"
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
)
|
||||
//关联生命周期
|
||||
binding.lifecycleOwner = this
|
||||
@@ -56,7 +60,11 @@ class MainActivity : BaseActivity() {
|
||||
//处理页面跳转
|
||||
viewModel.navigation(this, it)
|
||||
}
|
||||
|
||||
binding.mainActivitySignRecyclerview.layoutManager = LinearLayoutManager(this)
|
||||
binding.mainActivitySignRecyclerview.adapter = signAdapter
|
||||
viewModel.liveDataSignList.observe(this) {
|
||||
signAdapter.refreshData(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@@ -64,15 +72,10 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
//开启定位
|
||||
mapController.locationLayerHandler.startLocation()
|
||||
|
||||
//启动轨迹存储
|
||||
mapController.locationLayerHandler.setNiLocationListener(NiLocationListener {
|
||||
//ToastUtils.showLong("定位${it.longitude}")
|
||||
binding!!.viewModel!!.addSaveTrace(it)
|
||||
binding!!.viewModel!!.startSaveTraceThread(this)
|
||||
})
|
||||
//显示轨迹图层
|
||||
// mapController.layerManagerHandler.showNiLocationLayer(Constant.DATA_PATH+ SystemConstant.USER_ID+"/trace.sqlite")
|
||||
mapController.layerManagerHandler.showNiLocationLayer()
|
||||
// viewModel.startSaveTraceThread(this)
|
||||
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@@ -103,7 +106,7 @@ class MainActivity : BaseActivity() {
|
||||
*/
|
||||
fun openCamera() {
|
||||
//显示轨迹图层
|
||||
binding!!.viewModel!!.onClickCameraButton(this)
|
||||
viewModel.onClickCameraButton(this)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,23 +2,33 @@ package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.findNavController
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.NiLocationListener
|
||||
import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.ui.dialog.CommonDialog
|
||||
import com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ActivityContext
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import io.realm.RealmSet
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.videolan.libvlc.LibVlcUtil
|
||||
import javax.inject.Inject
|
||||
@@ -26,15 +36,25 @@ import javax.inject.Inject
|
||||
/**
|
||||
* 创建Activity全局viewmode
|
||||
*/
|
||||
|
||||
@HiltViewModel
|
||||
class MainViewModel @Inject constructor(
|
||||
private val mapController: NIMapController,
|
||||
private val traceDataBase: TraceDataBase,
|
||||
private val realmOperateHelper: RealmOperateHelper
|
||||
) : ViewModel() {
|
||||
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
private var mCameraDialog: CommonDialog? = null
|
||||
|
||||
private var niLocationList: MutableList<NiLocation> = ArrayList<NiLocation>()
|
||||
//地图点击捕捉到的质检数据ID列表
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
|
||||
//看板数据
|
||||
val liveDataSignList = MutableLiveData<List<SignBean>>()
|
||||
|
||||
|
||||
// private var niLocationList: MutableList<NiLocation> = ArrayList<NiLocation>()
|
||||
var testPoint = GeoPoint(0, 0)
|
||||
|
||||
init {
|
||||
mapController.markerHandle.setOnQsRecordItemClickListener(object :
|
||||
@@ -43,6 +63,93 @@ class MainViewModel @Inject constructor(
|
||||
liveDataQsRecordIdList.value = list
|
||||
}
|
||||
})
|
||||
initLocation()
|
||||
viewModelScope.launch {
|
||||
mapController.onMapClickFlow.collect {
|
||||
testPoint = it
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initLocation() {
|
||||
// mapController.locationLayerHandler.setNiLocationListener(NiLocationListener {
|
||||
// addSaveTrace(it)
|
||||
//
|
||||
// })
|
||||
//用于定位点存储到数据库
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||
location.longitude = testPoint.longitude
|
||||
location.latitude = testPoint.latitude
|
||||
val geometry = GeometryTools.createGeometry(
|
||||
GeoPoint(
|
||||
location.latitude,
|
||||
location.longitude
|
||||
)
|
||||
)
|
||||
val tileX = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
val tileY = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
|
||||
//遍历存储tile对应的x与y的值
|
||||
tileX.forEach { x ->
|
||||
tileY.forEach { y ->
|
||||
location.tilex = x
|
||||
location.tiley = y
|
||||
}
|
||||
}
|
||||
Log.e("jingo", "定位点插入 ${Thread.currentThread().name}")
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
}
|
||||
}
|
||||
//用于定位点捕捉道路
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||
Log.e("jingo", "定位点绑定道路 ${Thread.currentThread().name}")
|
||||
location.longitude = testPoint.longitude
|
||||
location.latitude = testPoint.latitude
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
location.longitude,
|
||||
location.latitude
|
||||
),
|
||||
)
|
||||
//看板数据
|
||||
val signList = mutableListOf<SignBean>()
|
||||
if (linkList.isNotEmpty()) {
|
||||
val link = linkList[0]
|
||||
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
linkId?.let {
|
||||
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
|
||||
for (element in elementList) {
|
||||
val distance = GeometryTools.distanceToDouble(
|
||||
GeoPoint(
|
||||
location.latitude, location.longitude,
|
||||
),
|
||||
GeometryTools.createGeoPoint(element.geometry)
|
||||
)
|
||||
signList.add(
|
||||
SignBean(
|
||||
iconId = R.drawable.icon_speed_limit,
|
||||
iconText = element.name,
|
||||
distance = distance.toInt(),
|
||||
)
|
||||
)
|
||||
}
|
||||
liveDataSignList.postValue(signList)
|
||||
Log.e("jingo", "自动捕捉数据 共${elementList.size}条")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//显示轨迹图层
|
||||
mapController.layerManagerHandler.showNiLocationLayer()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,6 +161,9 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}
|
||||
|
||||
//点击相机按钮
|
||||
@@ -96,49 +206,61 @@ class MainViewModel @Inject constructor(
|
||||
})
|
||||
}
|
||||
|
||||
fun startSaveTraceThread(context: Context) {
|
||||
Thread(Runnable {
|
||||
try {
|
||||
while (true) {
|
||||
|
||||
if (niLocationList != null && niLocationList.size > 0) {
|
||||
// fun startSaveTraceThread(context: Context) {
|
||||
// Thread(Runnable {
|
||||
// try {
|
||||
// while (true) {
|
||||
//
|
||||
// if (niLocationList != null && niLocationList.size > 0) {
|
||||
//
|
||||
// var niLocation = niLocationList[0]
|
||||
// val geometry = GeometryTools.createGeometry(
|
||||
// GeoPoint(
|
||||
// niLocation.latitude,
|
||||
// niLocation.longitude
|
||||
// )
|
||||
// )
|
||||
// val tileX = RealmSet<Int>()
|
||||
// GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
// val tileY = RealmSet<Int>()
|
||||
// GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
//
|
||||
// //遍历存储tile对应的x与y的值
|
||||
// tileX.forEach { x ->
|
||||
// tileY.forEach { y ->
|
||||
// niLocation.tilex = x
|
||||
// niLocation.tiley = y
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// TraceDataBase.getDatabase(
|
||||
// context,
|
||||
// Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
// ).niLocationDao.insert(niLocation)
|
||||
// niLocationList.remove(niLocation)
|
||||
//
|
||||
// Log.e("qj", "saveTrace==${niLocationList.size}")
|
||||
// }
|
||||
// Thread.sleep(30)
|
||||
// }
|
||||
// } catch (e: InterruptedException) {
|
||||
// e.printStackTrace()
|
||||
// Log.e("qj", "异常==${e.message}")
|
||||
// }
|
||||
// }).start()
|
||||
// }
|
||||
|
||||
var niLocation = niLocationList[0]
|
||||
val geometry = GeometryTools.createGeometry(GeoPoint(niLocation.latitude,niLocation.longitude))
|
||||
val tileX = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
val tileY = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
|
||||
//遍历存储tile对应的x与y的值
|
||||
tileX.forEach { x ->
|
||||
tileY.forEach { y ->
|
||||
niLocation.tilex = x
|
||||
niLocation.tiley = y
|
||||
}
|
||||
}
|
||||
|
||||
TraceDataBase.getDatabase(context, Constant.USER_DATA_PATH + "/trace.sqlite").niLocationDao.insert(niLocation)
|
||||
niLocationList.remove(niLocation)
|
||||
|
||||
Log.e("qj", "saveTrace==${niLocationList.size}")
|
||||
}
|
||||
Thread.sleep(30)
|
||||
}
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
Log.e("qj", "异常==${e.message}")
|
||||
}
|
||||
}).start()
|
||||
}
|
||||
|
||||
//增加轨迹存储
|
||||
fun addSaveTrace(niLocation: NiLocation) {
|
||||
if (niLocation != null && niLocationList != null) {
|
||||
niLocationList.add(niLocation)
|
||||
}
|
||||
}
|
||||
// //增加轨迹存储
|
||||
// fun addSaveTrace(niLocation: NiLocation) {
|
||||
// if (niLocation != null && niLocationList != null) {
|
||||
// niLocationList.add(niLocation)
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 处理页面调转
|
||||
*/
|
||||
fun navigation(activity: MainActivity, list: List<String>) {
|
||||
//获取右侧fragment容器
|
||||
val naviController = activity.findNavController(R.id.main_activity_right_fragment)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.AdapterSignBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
|
||||
class SignAdapter : BaseRecyclerViewAdapter<SignBean>() {
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_sign
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
AdapterSignBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val bd = holder.viewBinding as AdapterSignBinding
|
||||
val item = data[position]
|
||||
bd.signMainIcon.background = holder.viewBinding.root.context.getDrawable(item.iconId)
|
||||
bd.signMainIcon.text = item.iconText
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
data class SignBean(
|
||||
//图标ID
|
||||
val iconId: Int,
|
||||
val distance: Int = 0,
|
||||
val iconText: String = ""
|
||||
)
|
||||
@@ -8,7 +8,6 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
|
||||
import com.navinfo.collect.library.map.GeoPoint
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
@@ -18,10 +17,10 @@ import io.realm.Realm
|
||||
import io.realm.kotlin.where
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
@HiltViewModel
|
||||
class EvaluationResultViewModel @Inject constructor(
|
||||
private val roomAppDatabase: RoomAppDatabase,
|
||||
@@ -59,24 +58,24 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
init {
|
||||
liveDataQsRecordBean.value = QsRecordBean(id = UUID.randomUUID().toString())
|
||||
Log.e("jingo", "EvaluationResultViewModel 创建了 ${hashCode()}")
|
||||
mapController.markerHandle.run {
|
||||
setOnMapClickListener {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
addMarker(it, markerTitle)
|
||||
viewModelScope.launch {
|
||||
mapController.onMapClickFlow.collect {
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(it, markerTitle)
|
||||
viewModelScope.launch {
|
||||
captureLink(it.longitude, it.latitude)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
Log.e("jingo", "EvaluationResultViewModel 销毁了 ${hashCode()}")
|
||||
mapController.markerHandle.removeMarker(markerTitle)
|
||||
mapController.markerHandle.removeOnMapClickListener()
|
||||
mapController.lineHandler.removeLine()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +89,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
}
|
||||
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
|
||||
geoPoint?.let {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
||||
viewModelScope.launch {
|
||||
captureLink(geoPoint.longitude, geoPoint.latitude)
|
||||
@@ -102,20 +101,23 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
* 捕捉到路
|
||||
*/
|
||||
private suspend fun captureLink(longitude: Double, latitude: Double) {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
longitude,
|
||||
latitude
|
||||
),
|
||||
)
|
||||
liveDataQsRecordBean.value?.let {
|
||||
if (linkList.isNotEmpty()) {
|
||||
it.linkId =
|
||||
linkList[0].properties[LinkTable.linkPid] ?: ""
|
||||
mapController.lineHandler.showLine(linkList[0].geometry)
|
||||
} else {
|
||||
it.linkId = ""
|
||||
mapController.lineHandler.removeLine()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
longitude,
|
||||
latitude
|
||||
),
|
||||
)
|
||||
|
||||
liveDataQsRecordBean.value?.let {
|
||||
if (linkList.isNotEmpty()) {
|
||||
it.linkId =
|
||||
linkList[0].properties[LinkTable.linkPid] ?: ""
|
||||
mapController.lineHandler.showLine(linkList[0].geometry)
|
||||
} else {
|
||||
it.linkId = ""
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,23 +278,26 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
*/
|
||||
|
||||
fun initData(id: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects = realm.where<QsRecordBean>().equalTo("id", id).findFirst()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects = realm.where<QsRecordBean>().equalTo("id", id).findFirst()
|
||||
|
||||
if (objects != null) {
|
||||
oldBean = realm.copyFromRealm(objects)
|
||||
oldBean?.let {
|
||||
liveDataQsRecordBean.postValue(it.copy())
|
||||
val p = GeometryTools.createGeoPoint(it.geometry)
|
||||
mapController.markerHandle.addMarker(
|
||||
GeoPoint(p.longitude, p.latitude),
|
||||
markerTitle
|
||||
)
|
||||
if (it.linkId.isNotEmpty()) {
|
||||
val link = realmOperateHelper.queryLink(it.linkId)
|
||||
link?.let { l ->
|
||||
mapController.lineHandler.showLine(l.geometry)
|
||||
if (objects != null) {
|
||||
oldBean = realm.copyFromRealm(objects)
|
||||
oldBean?.let {
|
||||
liveDataQsRecordBean.postValue(it.copy())
|
||||
val p = GeometryTools.createGeoPoint(it.geometry)
|
||||
mapController.markerHandle.addMarker(
|
||||
GeoPoint(p.latitude, p.longitude),
|
||||
markerTitle
|
||||
)
|
||||
|
||||
if (it.linkId.isNotEmpty()) {
|
||||
val link = realmOperateHelper.queryLink(it.linkId)
|
||||
link?.let { l ->
|
||||
mapController.lineHandler.showLine(l.geometry)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.navinfo.omqs.ui.fragment.evaluationresult
|
||||
|
||||
import android.os.Build
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.TextItemSelectBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
@@ -21,6 +23,7 @@ class MiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null)
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val bd = holder.viewBinding as TextItemSelectBinding
|
||||
val title = data[position]
|
||||
|
||||
Reference in New Issue
Block a user