Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
Conflicts: app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt app/src/main/java/com/navinfo/omqs/ui/fragment/tasklist/TaskViewModel.kt collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt
This commit is contained in:
commit
c3f299222a
@ -131,6 +131,8 @@ dependencies {
|
|||||||
//图片加载
|
//图片加载
|
||||||
implementation 'com.github.bumptech.glide:glide:4.15.1'
|
implementation 'com.github.bumptech.glide:glide:4.15.1'
|
||||||
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"
|
||||||
|
|
||||||
}
|
}
|
||||||
//允许引用生成的代码
|
//允许引用生成的代码
|
||||||
kapt {
|
kapt {
|
||||||
|
@ -94,6 +94,8 @@ class Constant {
|
|||||||
const val EVENT_LAYER_MANAGER_CHANGE = "EVENT_LAYER_MANAGER_CHANGE" // 图层管理中的配置修改
|
const val EVENT_LAYER_MANAGER_CHANGE = "EVENT_LAYER_MANAGER_CHANGE" // 图层管理中的配置修改
|
||||||
|
|
||||||
const val SELECT_TASK_ID = "select_task_id" //选中的任务ID
|
const val SELECT_TASK_ID = "select_task_id" //选中的任务ID
|
||||||
|
|
||||||
|
const val SHARED_SYNC_TASK_LINK_ID = "shared_sync_task_link_id"//利用shared通知任务页面更新
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,11 +18,14 @@ import android.widget.PopupWindow
|
|||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import com.blankj.utilcode.util.ToastUtils
|
import com.blankj.utilcode.util.ToastUtils
|
||||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||||
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.QsRecordBean
|
||||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||||
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
|
||||||
@ -43,6 +46,7 @@ import com.navinfo.omqs.util.SpeakMode
|
|||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.RealmSet
|
import io.realm.RealmSet
|
||||||
|
import io.realm.kotlin.where
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@ -65,7 +69,7 @@ class MainViewModel @Inject constructor(
|
|||||||
private val mapController: NIMapController,
|
private val mapController: NIMapController,
|
||||||
private val traceDataBase: TraceDataBase,
|
private val traceDataBase: TraceDataBase,
|
||||||
private val realmOperateHelper: RealmOperateHelper,
|
private val realmOperateHelper: RealmOperateHelper,
|
||||||
private val sharedPreferences: SharedPreferences,
|
private val sharedPreferences: SharedPreferences
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
private var mCameraDialog: CommonDialog? = null
|
private var mCameraDialog: CommonDialog? = null
|
||||||
@ -158,12 +162,15 @@ class MainViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
initTaskData()
|
initTaskData()
|
||||||
|
initQsRecordData()
|
||||||
|
initNoteData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始话任务高亮高亮
|
* 初始化选中的任务高亮高亮
|
||||||
*/
|
*/
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
@RequiresApi(Build.VERSION_CODES.M)
|
||||||
private fun initTaskData() {
|
private fun initTaskData() {
|
||||||
@ -182,11 +189,54 @@ class MainViewModel @Inject constructor(
|
|||||||
for (item in list) {
|
for (item in list) {
|
||||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
|
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
|
||||||
}
|
}
|
||||||
|
private suspend fun initTaskData() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||||
|
val realm = Realm.getDefaultInstance()
|
||||||
|
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
|
||||||
|
if (res != null) {
|
||||||
|
val taskBean = realm.copyFromRealm(res)
|
||||||
|
mapController.lineHandler.omdbTaskLinkLayer.addLineList(taskBean.hadLinkDvoList)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化渲染质检数据
|
||||||
|
*/
|
||||||
|
private suspend fun initQsRecordData() {
|
||||||
|
var list = mutableListOf<QsRecordBean>()
|
||||||
|
val realm = Realm.getDefaultInstance()
|
||||||
|
realm.executeTransaction {
|
||||||
|
val objects = realm.where<QsRecordBean>().findAll()
|
||||||
|
list = realm.copyFromRealm(objects)
|
||||||
|
}
|
||||||
|
for (item in list) {
|
||||||
|
mapController.markerHandle.addOrUpdateQsRecordMark(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化渲染便签数据
|
||||||
|
*/
|
||||||
|
private suspend fun initNoteData() {
|
||||||
|
var list = mutableListOf<NoteBean>()
|
||||||
|
val realm = Realm.getDefaultInstance()
|
||||||
|
realm.executeTransaction {
|
||||||
|
val objects = realm.where<NoteBean>().findAll()
|
||||||
|
list = realm.copyFromRealm(objects)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (item in list) {
|
||||||
|
mapController.markerHandle.addOrUpdateNoteMark(item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化定位信息
|
||||||
|
*/
|
||||||
private fun initLocation() {
|
private fun initLocation() {
|
||||||
//用于定位点存储到数据库
|
//用于定位点存储到数据库
|
||||||
viewModelScope.launch(Dispatchers.Default) {
|
viewModelScope.launch(Dispatchers.Default) {
|
||||||
|
@ -6,7 +6,6 @@ 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 android.widget.Toast
|
||||||
import androidx.fragment.app.viewModels
|
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.navinfo.collect.library.map.NIMapController
|
import com.navinfo.collect.library.map.NIMapController
|
||||||
@ -14,7 +13,6 @@ import com.navinfo.omqs.R
|
|||||||
import com.navinfo.omqs.databinding.FragmentTaskLinkBinding
|
import com.navinfo.omqs.databinding.FragmentTaskLinkBinding
|
||||||
import com.navinfo.omqs.ui.activity.map.MainActivity
|
import com.navinfo.omqs.ui.activity.map.MainActivity
|
||||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||||
import com.navinfo.omqs.ui.other.BaseToast
|
|
||||||
import com.navinfo.omqs.ui.other.shareViewModels
|
import com.navinfo.omqs.ui.other.shareViewModels
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -144,7 +142,9 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
|||||||
onBackPressed()
|
onBackPressed()
|
||||||
}
|
}
|
||||||
binding.taskLinkBarSave -> {
|
binding.taskLinkBarSave -> {
|
||||||
viewModel.saveData()
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
viewModel.saveData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,14 @@ package com.navinfo.omqs.ui.fragment.tasklink
|
|||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
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
|
||||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||||
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.utils.GeometryTools
|
||||||
import com.navinfo.omqs.Constant
|
import com.navinfo.omqs.Constant
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
@ -22,14 +24,14 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class TaskLinkViewModel @Inject constructor(
|
class TaskLinkViewModel @Inject constructor(
|
||||||
val mapController: NIMapController,
|
private val mapController: NIMapController,
|
||||||
val sharedPreferences: SharedPreferences
|
private val sharedPreferences: SharedPreferences
|
||||||
) : ViewModel(), SharedPreferences.OnSharedPreferenceChangeListener {
|
) : ViewModel(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 种别
|
* 种别
|
||||||
*/
|
*/
|
||||||
private val kindList = listOf<TaskLinkInfoAdapterItem>(
|
private val kindList = listOf(
|
||||||
TaskLinkInfoAdapterItem("高速道路", "1"),
|
TaskLinkInfoAdapterItem("高速道路", "1"),
|
||||||
TaskLinkInfoAdapterItem("城市高速", "2"),
|
TaskLinkInfoAdapterItem("城市高速", "2"),
|
||||||
TaskLinkInfoAdapterItem("国道", "3"),
|
TaskLinkInfoAdapterItem("国道", "3"),
|
||||||
@ -47,7 +49,7 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* FunctionGrade 功能等级
|
* FunctionGrade 功能等级
|
||||||
*/
|
*/
|
||||||
private val functionLevelList = listOf<TaskLinkInfoAdapterItem>(
|
private val functionLevelList = listOf(
|
||||||
TaskLinkInfoAdapterItem("等级1", "1"),
|
TaskLinkInfoAdapterItem("等级1", "1"),
|
||||||
TaskLinkInfoAdapterItem("等级2", "2"),
|
TaskLinkInfoAdapterItem("等级2", "2"),
|
||||||
TaskLinkInfoAdapterItem("等级3", "3"),
|
TaskLinkInfoAdapterItem("等级3", "3"),
|
||||||
@ -58,7 +60,7 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* 数据级别
|
* 数据级别
|
||||||
*/
|
*/
|
||||||
private val dataLevelList = listOf<TaskLinkInfoAdapterItem>(
|
private val dataLevelList = listOf(
|
||||||
TaskLinkInfoAdapterItem("Pro lane model(有高精车道模型覆盖的高速和城高link)", "1"),
|
TaskLinkInfoAdapterItem("Pro lane model(有高精车道模型覆盖的高速和城高link)", "1"),
|
||||||
TaskLinkInfoAdapterItem("Lite lane model(有高精车道模型覆盖的普通路link)", "2"),
|
TaskLinkInfoAdapterItem("Lite lane model(有高精车道模型覆盖的普通路link)", "2"),
|
||||||
TaskLinkInfoAdapterItem("Standard road model(其他link)", "3"),
|
TaskLinkInfoAdapterItem("Standard road model(其他link)", "3"),
|
||||||
@ -115,7 +117,7 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
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()
|
||||||
liveDataTaskBean.postValue(realm.copyFromRealm(res))
|
liveDataTaskBean.postValue(res?.let { realm.copyFromRealm(it) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,18 +164,17 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* 保存数据
|
* 保存数据
|
||||||
*/
|
*/
|
||||||
|
@RequiresApi(Build.VERSION_CODES.M)
|
||||||
fun saveData() {
|
fun saveData() {
|
||||||
viewModelScope.launch(Dispatchers.Default) {
|
viewModelScope.launch(Dispatchers.Default) {
|
||||||
if (liveDataTaskBean.value == null) {
|
if (liveDataTaskBean.value == null) {
|
||||||
liveDataToastMessage.postValue("还没有选择任何一条任务!")
|
liveDataToastMessage.postValue("还没有选择任何一条任务!")
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
|
|
||||||
if (mapController.measureLayerHandler.mPathLayer.points.size < 2) {
|
if (mapController.measureLayerHandler.mPathLayer.points.size < 2) {
|
||||||
liveDataToastMessage.postValue("道路点少于2个!")
|
liveDataToastMessage.postValue("道路点少于2个!")
|
||||||
return@launch
|
return@launch
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (liveDataSelectKind.value == null) {
|
if (liveDataSelectKind.value == null) {
|
||||||
liveDataToastMessage.postValue("请选择种别!")
|
liveDataToastMessage.postValue("请选择种别!")
|
||||||
@ -187,7 +188,21 @@ class TaskLinkViewModel @Inject constructor(
|
|||||||
liveDataToastMessage.postValue("请选择数据等级!")
|
liveDataToastMessage.postValue("请选择数据等级!")
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
val linkBean = HadLinkDvoBean(linkPid = UUID.randomUUID().toString())
|
val linkBean = HadLinkDvoBean(
|
||||||
|
linkPid = UUID.randomUUID().toString(),
|
||||||
|
linkStatus = 3,
|
||||||
|
geometry = GeometryTools.getLineString(mapController.measureLayerHandler.mPathLayer.points),
|
||||||
|
linkLength = mapController.measureLayerHandler.lineLenghtLiveData.value!!,
|
||||||
|
)
|
||||||
|
val task: TaskBean = liveDataTaskBean.value!!
|
||||||
|
task.hadLinkDvoList.add(linkBean)
|
||||||
|
val realm = Realm.getDefaultInstance()
|
||||||
|
realm.executeTransaction {
|
||||||
|
it.copyToRealmOrUpdate(task)
|
||||||
|
}
|
||||||
|
sharedPreferences.edit().putString(Constant.SHARED_SYNC_TASK_LINK_ID, linkBean.linkPid)
|
||||||
|
.apply()
|
||||||
|
liveDataFinish.postValue(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
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.graphics.Color
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
@ -51,6 +50,8 @@ class TaskViewModel @Inject constructor(
|
|||||||
*/
|
*/
|
||||||
val liveDataTaskUpload = MutableLiveData<Map<TaskBean, Boolean>>()
|
val liveDataTaskUpload = MutableLiveData<Map<TaskBean, Boolean>>()
|
||||||
|
|
||||||
|
// private val colors =
|
||||||
|
// arrayOf(Color.RED, Color.YELLOW, Color.BLUE, Color.MAGENTA, Color.GREEN, Color.CYAN)
|
||||||
/**
|
/**
|
||||||
* 用来确定是否关闭
|
* 用来确定是否关闭
|
||||||
*/
|
*/
|
||||||
@ -72,13 +73,16 @@ class TaskViewModel @Inject constructor(
|
|||||||
private var filterTaskJob: Job? = null
|
private var filterTaskJob: Job? = null
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载任务列表
|
* 下载任务列表
|
||||||
*/
|
*/
|
||||||
fun getTaskList(context: Context) {
|
fun getTaskList(context: Context) {
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
|
||||||
var taskList: List<TaskBean> = mutableListOf()
|
|
||||||
when (val result = networkService.getTaskList(Constant.USER_ID)) {
|
when (val result = networkService.getTaskList(Constant.USER_ID)) {
|
||||||
is NetResult.Success -> {
|
is NetResult.Success -> {
|
||||||
if (result.data != null) {
|
if (result.data != null) {
|
||||||
@ -94,6 +98,7 @@ class TaskViewModel @Inject constructor(
|
|||||||
task.fileSize = item.fileSize
|
task.fileSize = item.fileSize
|
||||||
task.status = item.status
|
task.status = item.status
|
||||||
task.currentSize = item.currentSize
|
task.currentSize = item.currentSize
|
||||||
|
task.hadLinkDvoList = item.hadLinkDvoList
|
||||||
//已上传后不在更新操作时间
|
//已上传后不在更新操作时间
|
||||||
if (task.syncStatus != FileManager.Companion.FileUploadStatus.DONE) {
|
if (task.syncStatus != FileManager.Companion.FileUploadStatus.DONE) {
|
||||||
//赋值时间,用于查询过滤
|
//赋值时间,用于查询过滤
|
||||||
@ -127,27 +132,40 @@ class TaskViewModel @Inject constructor(
|
|||||||
|
|
||||||
is NetResult.Loading -> {}
|
is NetResult.Loading -> {}
|
||||||
}
|
}
|
||||||
val realm = Realm.getDefaultInstance()
|
getLocalTaskList()
|
||||||
//过滤掉已上传的超过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)
|
private suspend fun getLocalTaskList() {
|
||||||
.equalTo("syncStatus", syncUpload).findAll()
|
val realm = Realm.getDefaultInstance()
|
||||||
taskList = realm.copyFromRealm(objects)
|
//过滤掉已上传的超过90天的数据
|
||||||
|
val nowTime: Long = DateTimeUtil.getNowDate().time
|
||||||
|
val beginNowTime: Long = nowTime - 90 * 3600 * 24 * 1000L
|
||||||
|
val 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)
|
||||||
|
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||||
|
if (id > -1) {
|
||||||
for (item in taskList) {
|
for (item in taskList) {
|
||||||
FileManager.checkOMDBFileInfo(item)
|
if (item.id == id) {
|
||||||
}
|
currentSelectTaskBean = item
|
||||||
liveDataTaskList.postValue(taskList)
|
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
||||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
withContext(Dispatchers.Main) {
|
||||||
if (id > -1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
for(item in taskList){
|
showTaskLinks(currentSelectTaskBean!!)
|
||||||
if(item.id == id){
|
}
|
||||||
currentSelectTaskBean = item
|
|
||||||
liveDataTaskLinks.postValue(currentSelectTaskBean!!.hadLinkDvoList)
|
|
||||||
}
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,14 +174,21 @@ class TaskViewModel @Inject constructor(
|
|||||||
/**
|
/**
|
||||||
* 设置当前选择的任务,并高亮当前任务的所有link
|
* 设置当前选择的任务,并高亮当前任务的所有link
|
||||||
*/
|
*/
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
fun setSelectTaskBean(taskBean: TaskBean) {
|
fun setSelectTaskBean(taskBean: TaskBean) {
|
||||||
|
|
||||||
sharedPreferences.edit().putInt(Constant.SELECT_TASK_ID, taskBean.id).commit()
|
sharedPreferences.edit().putInt(Constant.SELECT_TASK_ID, taskBean.id).apply()
|
||||||
|
|
||||||
currentSelectTaskBean = taskBean
|
currentSelectTaskBean = taskBean
|
||||||
|
|
||||||
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
liveDataTaskLinks.value = taskBean.hadLinkDvoList
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
showTaskLinks(taskBean)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.M)
|
||||||
|
private fun showTaskLinks(taskBean: TaskBean) {
|
||||||
|
|
||||||
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
|
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
|
||||||
mapController.markerHandle.clearNiLocationLayer()
|
mapController.markerHandle.clearNiLocationLayer()
|
||||||
@ -238,7 +263,9 @@ class TaskViewModel @Inject constructor(
|
|||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存link补作业原因
|
||||||
|
*/
|
||||||
suspend fun saveLinkReason(bean: HadLinkDvoBean, text: String) {
|
suspend fun saveLinkReason(bean: HadLinkDvoBean, text: String) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
currentSelectTaskBean?.let {
|
currentSelectTaskBean?.let {
|
||||||
@ -247,11 +274,12 @@ class TaskViewModel @Inject constructor(
|
|||||||
item.reason = text
|
item.reason = text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val realm = Realm.getDefaultInstance()
|
||||||
|
realm.executeTransaction { r ->
|
||||||
|
r.copyToRealmOrUpdate(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val realm = Realm.getDefaultInstance()
|
|
||||||
realm.executeTransaction {
|
|
||||||
realm.copyToRealmOrUpdate(currentSelectTaskBean)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,6 +303,9 @@ class TaskViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 筛选link
|
||||||
|
*/
|
||||||
fun filterTask(pidKey: String) {
|
fun filterTask(pidKey: String) {
|
||||||
if (currentSelectTaskBean == null)
|
if (currentSelectTaskBean == null)
|
||||||
return
|
return
|
||||||
@ -292,6 +323,9 @@ class TaskViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭任务
|
||||||
|
*/
|
||||||
fun removeTask(context: Context, taskBean: TaskBean) {
|
fun removeTask(context: Context, taskBean: TaskBean) {
|
||||||
if (taskBean != null) {
|
if (taskBean != null) {
|
||||||
val mDialog = FirstDialog(context)
|
val mDialog = FirstDialog(context)
|
||||||
@ -345,6 +379,50 @@ class TaskViewModel @Inject constructor(
|
|||||||
})
|
})
|
||||||
mDialog.show()
|
mDialog.show()
|
||||||
}
|
}
|
||||||
|
val mDialog = FirstDialog(context)
|
||||||
|
mDialog.setTitle("提示?")
|
||||||
|
mDialog.setMessage("是否关闭,请确认!")
|
||||||
|
mDialog.setPositiveButton(
|
||||||
|
"确定"
|
||||||
|
) { _, _ ->
|
||||||
|
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天的数据
|
||||||
|
val nowTime: Long = DateTimeUtil.getNowDate().time
|
||||||
|
val beginNowTime: Long = nowTime - 90 * 3600 * 24 * 1000L
|
||||||
|
val 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mDialog.setNegativeButton("取消", null)
|
||||||
|
mDialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkUploadTask(context: Context, taskBean: TaskBean) {
|
fun checkUploadTask(context: Context, taskBean: TaskBean) {
|
||||||
@ -361,19 +439,15 @@ class TaskViewModel @Inject constructor(
|
|||||||
mDialog.setTitle("提示?")
|
mDialog.setTitle("提示?")
|
||||||
mDialog.setMessage("此任务中存在未测评link,请确认!")
|
mDialog.setMessage("此任务中存在未测评link,请确认!")
|
||||||
mDialog.setPositiveButton(
|
mDialog.setPositiveButton(
|
||||||
"确定",
|
"确定"
|
||||||
object : FirstDialog.OnClickListener {
|
) { _, _ ->
|
||||||
override fun onClick(dialog: Dialog?, which: Int) {
|
mDialog.dismiss()
|
||||||
mDialog.dismiss()
|
map[taskBean] = true
|
||||||
map[taskBean] = true
|
liveDataTaskUpload.postValue(map)
|
||||||
liveDataTaskUpload.postValue(map)
|
}
|
||||||
}
|
mDialog.setNegativeButton(
|
||||||
})
|
"取消"
|
||||||
mDialog.setNegativeButton("取消", object : FirstDialog.OnClickListener {
|
) { _, _ -> mDialog.dismiss() }
|
||||||
override fun onClick(dialog: Dialog?, which: Int) {
|
|
||||||
mDialog.dismiss()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
mDialog.show()
|
mDialog.show()
|
||||||
}
|
}
|
||||||
return@launch
|
return@launch
|
||||||
@ -383,4 +457,15 @@ class TaskViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听新增的评测link
|
||||||
|
*/
|
||||||
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
|
if (key == Constant.SHARED_SYNC_TASK_LINK_ID) {
|
||||||
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
getLocalTaskList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,12 +64,52 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
/**
|
/**
|
||||||
* 文字画笔
|
* 文字画笔
|
||||||
*/
|
*/
|
||||||
|
private val paint: Paint by lazy {
|
||||||
|
val p = CanvasAdapter.newPaint()
|
||||||
|
p.setTypeface(Paint.FontFamily.DEFAULT, Paint.FontStyle.NORMAL)
|
||||||
|
p.setTextSize(NUM_13 * CanvasAdapter.getScale())
|
||||||
|
p.strokeWidth = 2 * CanvasAdapter.getScale()
|
||||||
|
p.color = Color.parseColor(mDefaultTextColor)
|
||||||
|
p
|
||||||
|
}
|
||||||
|
|
||||||
private lateinit var paint: Paint
|
/**
|
||||||
|
* 画布
|
||||||
|
*/
|
||||||
|
private val canvas: org.oscim.backend.canvas.Canvas by lazy {
|
||||||
|
CanvasAdapter.newCanvas()
|
||||||
|
}
|
||||||
|
|
||||||
//画布
|
/**
|
||||||
private lateinit var canvas: org.oscim.backend.canvas.Canvas
|
* 默认marker图层
|
||||||
private lateinit var itemizedLayer: MyItemizedLayer
|
*/
|
||||||
|
private val mDefaultMarkerLayer: ItemizedLayer by lazy {
|
||||||
|
//新增marker图标样式
|
||||||
|
val mDefaultBitmap =
|
||||||
|
AndroidBitmap(BitmapFactory.decodeResource(context.resources, R.mipmap.marker))
|
||||||
|
|
||||||
|
val markerSymbol = MarkerSymbol(
|
||||||
|
mDefaultBitmap,
|
||||||
|
MarkerSymbol.HotspotPlace.BOTTOM_CENTER
|
||||||
|
)
|
||||||
|
val layer = ItemizedLayer(
|
||||||
|
mapView.vtmMap,
|
||||||
|
ArrayList(),
|
||||||
|
markerSymbol,
|
||||||
|
object : OnItemGestureListener<MarkerInterface> {
|
||||||
|
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemLongPress(index: Int, item: MarkerInterface?): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
|
||||||
|
layer
|
||||||
|
}
|
||||||
|
|
||||||
private lateinit var niLocationItemizedLayer: MyItemizedLayer
|
private lateinit var niLocationItemizedLayer: MyItemizedLayer
|
||||||
|
|
||||||
@ -83,9 +123,45 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
private var niLocationBitmap3: Bitmap? = null
|
private var niLocationBitmap3: Bitmap? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文字大小
|
* 评测数据marker 图层
|
||||||
*/
|
*/
|
||||||
private val NUM_13 = 13
|
private val qsRecordItemizedLayer: MyItemizedLayer by lazy {
|
||||||
|
val layer = MyItemizedLayer(
|
||||||
|
mMapView.vtmMap,
|
||||||
|
mutableListOf(),
|
||||||
|
markerRendererFactory,
|
||||||
|
object : MyItemizedLayer.OnItemGestureListener {
|
||||||
|
override fun onItemSingleTapUp(
|
||||||
|
list: MutableList<Int>,
|
||||||
|
nearest: Int
|
||||||
|
): Boolean {
|
||||||
|
itemListener?.let {
|
||||||
|
val idList = mutableListOf<String>()
|
||||||
|
if (list.size == 0) {
|
||||||
|
} else {
|
||||||
|
for (i in list) {
|
||||||
|
val markerInterface: MarkerInterface =
|
||||||
|
qsRecordItemizedLayer.itemList[i]
|
||||||
|
if (markerInterface is MarkerItem) {
|
||||||
|
idList.add(markerInterface.title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it.onQsRecordList(idList.distinct().toMutableList())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemLongPress(
|
||||||
|
list: MutableList<Int>?,
|
||||||
|
nearest: Int
|
||||||
|
): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
|
||||||
|
layer
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 便签线图层
|
* 便签线图层
|
||||||
@ -96,7 +172,9 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
layer
|
layer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 便签图标图层
|
||||||
|
*/
|
||||||
private val noteLayer: MyItemizedLayer by lazy {
|
private val noteLayer: MyItemizedLayer by lazy {
|
||||||
|
|
||||||
val layer = MyItemizedLayer(
|
val layer = MyItemizedLayer(
|
||||||
@ -111,6 +189,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
itemListener?.let {
|
itemListener?.let {
|
||||||
val idList = mutableListOf<String>()
|
val idList = mutableListOf<String>()
|
||||||
if (list.size == 0) {
|
if (list.size == 0) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (i in list) {
|
for (i in list) {
|
||||||
val markerInterface: MarkerInterface =
|
val markerInterface: MarkerInterface =
|
||||||
@ -137,6 +216,41 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
layer
|
layer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private val markerRendererFactory: MarkerRendererFactory by lazy {
|
||||||
|
val bitmapPoi: Bitmap = AndroidBitmap(
|
||||||
|
BitmapFactory.decodeResource(
|
||||||
|
mContext.resources,
|
||||||
|
R.mipmap.map_icon_blue2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val symbol = MarkerSymbol(bitmapPoi, MarkerSymbol.HotspotPlace.BOTTOM_CENTER)
|
||||||
|
MarkerRendererFactory { markerLayer ->
|
||||||
|
object : ClusterMarkerRenderer(
|
||||||
|
mContext,
|
||||||
|
markerLayer,
|
||||||
|
symbol,
|
||||||
|
ClusterStyle(
|
||||||
|
org.oscim.backend.canvas.Color.WHITE,
|
||||||
|
org.oscim.backend.canvas.Color.BLUE
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// override fun getClusterBitmap(size: Int): Bitmap? {
|
||||||
|
// return super.getclusterbitmap(size)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val resId = R.mipmap.map_icon_report
|
||||||
|
private val noteResId = R.drawable.icon_note_marker
|
||||||
|
private var itemListener: OnQsRecordItemClickListener? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文字大小
|
||||||
|
*/
|
||||||
|
private val NUM_13 = 13
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
//新增marker图标样式
|
//新增marker图标样式
|
||||||
val mDefaultBitmap =
|
val mDefaultBitmap =
|
||||||
@ -173,7 +287,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
// 设置矢量图层均在12级以上才显示
|
// 设置矢量图层均在12级以上才显示
|
||||||
mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
|
mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
|
||||||
if (e == Map.SCALE_EVENT) {
|
if (e == Map.SCALE_EVENT) {
|
||||||
itemizedLayer.isEnabled = mapPosition.getZoomLevel() >= 12
|
qsRecordItemizedLayer.isEnabled = mapPosition.getZoomLevel() >= 12
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
initNoteData()
|
initNoteData()
|
||||||
@ -182,11 +296,17 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
mMapView.updateMap()
|
mMapView.updateMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置marker 点击回调
|
||||||
|
*/
|
||||||
fun setOnQsRecordItemClickListener(listener: OnQsRecordItemClickListener?) {
|
fun setOnQsRecordItemClickListener(listener: OnQsRecordItemClickListener?) {
|
||||||
itemListener = listener
|
itemListener = listener
|
||||||
}
|
}
|
||||||
|
|
||||||
//增加marker
|
/**
|
||||||
|
* 增加marker
|
||||||
|
*/
|
||||||
|
|
||||||
fun addMarker(
|
fun addMarker(
|
||||||
geoPoint: GeoPoint,
|
geoPoint: GeoPoint,
|
||||||
title: String?,
|
title: String?,
|
||||||
@ -200,16 +320,16 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (marker == null) {
|
if (marker == null) {
|
||||||
var tempTitle = title;
|
var tempTitle = title
|
||||||
if (tempTitle.isNullOrBlank()) {
|
if (tempTitle.isNullOrBlank()) {
|
||||||
tempTitle = StringUtil.createUUID();
|
tempTitle = StringUtil.createUUID()
|
||||||
}
|
}
|
||||||
val marker = MarkerItem(
|
val marker = MarkerItem(
|
||||||
tempTitle,
|
tempTitle,
|
||||||
description,
|
description,
|
||||||
geoPoint
|
geoPoint
|
||||||
)
|
)
|
||||||
mDefaultMarkerLayer.addItem(marker);
|
mDefaultMarkerLayer.addItem(marker)
|
||||||
mMapView.vtmMap.updateMap(true)
|
mMapView.vtmMap.updateMap(true)
|
||||||
} else {
|
} else {
|
||||||
marker.description = description
|
marker.description = description
|
||||||
@ -237,29 +357,28 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加或更新marker
|
* 增加或更新marker
|
||||||
*/
|
*/
|
||||||
suspend fun addOrUpdateQsRecordMark(data: QsRecordBean) {
|
fun addOrUpdateQsRecordMark(data: QsRecordBean) {
|
||||||
for (item in itemizedLayer.itemList) {
|
for (item in qsRecordItemizedLayer.itemList) {
|
||||||
if (item is MarkerItem) {
|
if (item is MarkerItem) {
|
||||||
if (item.title == data.id) {
|
if (item.title == data.id) {
|
||||||
itemizedLayer.itemList.remove(item)
|
qsRecordItemizedLayer.itemList.remove(item)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createMarkerItem(data)
|
createQsRecordMarker(data)
|
||||||
withContext(Dispatchers.Main) {
|
mMapView.updateMap(true)
|
||||||
mMapView.updateMap(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加或更新便签
|
* 增加或更新便签
|
||||||
*/
|
*/
|
||||||
suspend fun addOrUpdateNoteMark(data: NoteBean) {
|
fun addOrUpdateNoteMark(data: NoteBean) {
|
||||||
for (item in noteLayer.itemList) {
|
for (item in noteLayer.itemList) {
|
||||||
if (item is MarkerItem) {
|
if (item is MarkerItem) {
|
||||||
if (item.title == data.id) {
|
if (item.title == data.id) {
|
||||||
@ -270,9 +389,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
}
|
}
|
||||||
noteLineLayer.removeNoteBeanLines(data)
|
noteLineLayer.removeNoteBeanLines(data)
|
||||||
createNoteMarkerItem(data)
|
createNoteMarkerItem(data)
|
||||||
withContext(Dispatchers.Main) {
|
mMapView.updateMap(true)
|
||||||
mMapView.updateMap(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -280,19 +397,13 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
var resultDrawable: Drawable? = null
|
var resultDrawable: Drawable? = null
|
||||||
if ("POINT" == geometry.geometryType.uppercase(Locale.getDefault())) {
|
if ("POINT" == geometry.geometryType.uppercase(Locale.getDefault())) {
|
||||||
val geoPoint = GeoPoint(geometry.coordinate.y, geometry.coordinate.x)
|
val geoPoint = GeoPoint(geometry.coordinate.y, geometry.coordinate.x)
|
||||||
if (geoPoint != null) {
|
resultDrawable = PointDrawable(geoPoint, vectorLayerStyle)
|
||||||
resultDrawable = PointDrawable(geoPoint, vectorLayerStyle)
|
|
||||||
}
|
|
||||||
} else if ("LINESTRING" == geometry.geometryType.uppercase(Locale.getDefault())) {
|
} else if ("LINESTRING" == geometry.geometryType.uppercase(Locale.getDefault())) {
|
||||||
val lineString = geometry as LineString
|
val lineString = geometry as LineString
|
||||||
if (lineString != null) {
|
resultDrawable = LineDrawable(lineString, vectorLayerStyle)
|
||||||
resultDrawable = LineDrawable(lineString, vectorLayerStyle)
|
|
||||||
}
|
|
||||||
} else if ("POLYGON" == geometry.geometryType.uppercase(Locale.getDefault())) {
|
} else if ("POLYGON" == geometry.geometryType.uppercase(Locale.getDefault())) {
|
||||||
val polygon = geometry as Polygon
|
val polygon = geometry as Polygon
|
||||||
if (polygon != null) {
|
resultDrawable = PolygonDrawable(polygon, vectorLayerStyle)
|
||||||
resultDrawable = PolygonDrawable(polygon, vectorLayerStyle)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return resultDrawable
|
return resultDrawable
|
||||||
}
|
}
|
||||||
@ -301,12 +412,12 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
/**
|
/**
|
||||||
* 删除质检数据
|
* 删除质检数据
|
||||||
*/
|
*/
|
||||||
suspend fun removeQsRecordMark(data: QsRecordBean) {
|
fun removeQsRecordMark(data: QsRecordBean) {
|
||||||
for (item in itemizedLayer.itemList) {
|
for (item in qsRecordItemizedLayer.itemList) {
|
||||||
if (item is MarkerItem) {
|
if (item is MarkerItem) {
|
||||||
if (item.title == data.id) {
|
if (item.title == data.id) {
|
||||||
itemizedLayer.itemList.remove(item)
|
qsRecordItemizedLayer.itemList.remove(item)
|
||||||
itemizedLayer.populate()
|
qsRecordItemizedLayer.populate()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,124 +427,39 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
/**
|
/**
|
||||||
* 删除标签
|
* 删除标签
|
||||||
*/
|
*/
|
||||||
suspend fun removeNoteMark(data: NoteBean) {
|
fun removeNoteMark(data: NoteBean) {
|
||||||
for (item in noteLayer.itemList) {
|
for (item in noteLayer.itemList) {
|
||||||
if (item is MarkerItem) {
|
if (item is MarkerItem) {
|
||||||
if (item.title == data.id) {
|
if (item.title == data.id) {
|
||||||
noteLayer.itemList.remove(item)
|
noteLayer.itemList.remove(item)
|
||||||
noteLineLayer.removeNoteBeanLines(data)
|
noteLineLayer.removeNoteBeanLines(data)
|
||||||
noteLayer.populate()
|
noteLayer.populate()
|
||||||
withContext(Dispatchers.Main) {
|
mMapView.updateMap(true)
|
||||||
mMapView.updateMap(true)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化便签
|
|
||||||
*/
|
|
||||||
private fun initNoteData() {
|
|
||||||
mContext.lifecycleScope.launch(Dispatchers.IO) {
|
|
||||||
var list = mutableListOf<NoteBean>()
|
|
||||||
val realm = Realm.getDefaultInstance()
|
|
||||||
realm.executeTransaction {
|
|
||||||
val objects = realm.where<NoteBean>().findAll()
|
|
||||||
list = realm.copyFromRealm(objects)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (item in list) {
|
// /**
|
||||||
createNoteMarkerItem(item)
|
// * 初始话质检数据图层
|
||||||
}
|
// */
|
||||||
}
|
// private fun initQsRecordDataLayer() {
|
||||||
}
|
//
|
||||||
|
// mContext.lifecycleScope.launch(Dispatchers.IO) {
|
||||||
/**
|
// var list = mutableListOf<QsRecordBean>()
|
||||||
* 初始话质检数据图层
|
// val realm = Realm.getDefaultInstance()
|
||||||
*/
|
// realm.executeTransaction {
|
||||||
private fun initQsRecordDataLayer() {
|
// val objects = realm.where<QsRecordBean>().findAll()
|
||||||
|
// list = realm.copyFromRealm(objects)
|
||||||
canvas = CanvasAdapter.newCanvas()
|
// }
|
||||||
paint = CanvasAdapter.newPaint()
|
// for (item in list) {
|
||||||
paint.setTypeface(Paint.FontFamily.DEFAULT, Paint.FontStyle.NORMAL)
|
// createMarkerItem(item)
|
||||||
paint.setTextSize(NUM_13 * CanvasAdapter.getScale())
|
// }
|
||||||
paint.strokeWidth = 2 * CanvasAdapter.getScale()
|
// }
|
||||||
paint.color = Color.parseColor(mDefaultTextColor)
|
//
|
||||||
val bitmapPoi: Bitmap = AndroidBitmap(
|
// }
|
||||||
BitmapFactory.decodeResource(
|
|
||||||
mContext.resources,
|
|
||||||
R.mipmap.map_icon_blue2
|
|
||||||
)
|
|
||||||
)
|
|
||||||
val symbol = MarkerSymbol(bitmapPoi, MarkerSymbol.HotspotPlace.BOTTOM_CENTER)
|
|
||||||
markerRendererFactory = MarkerRendererFactory { markerLayer ->
|
|
||||||
object : ClusterMarkerRenderer(
|
|
||||||
mContext,
|
|
||||||
markerLayer,
|
|
||||||
symbol,
|
|
||||||
ClusterStyle(
|
|
||||||
org.oscim.backend.canvas.Color.WHITE,
|
|
||||||
org.oscim.backend.canvas.Color.BLUE
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
// override fun getClusterBitmap(size: Int): Bitmap? {
|
|
||||||
// return super.getclusterbitmap(size)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
itemizedLayer =
|
|
||||||
MyItemizedLayer(
|
|
||||||
mMapView.vtmMap,
|
|
||||||
mutableListOf(),
|
|
||||||
markerRendererFactory,
|
|
||||||
object : MyItemizedLayer.OnItemGestureListener {
|
|
||||||
override fun onItemSingleTapUp(
|
|
||||||
list: MutableList<Int>,
|
|
||||||
nearest: Int
|
|
||||||
): Boolean {
|
|
||||||
itemListener?.let {
|
|
||||||
val idList = mutableListOf<String>()
|
|
||||||
if (list.size == 0) {
|
|
||||||
} else {
|
|
||||||
for (i in list) {
|
|
||||||
val markerInterface: MarkerInterface =
|
|
||||||
itemizedLayer.itemList[i]
|
|
||||||
if (markerInterface is MarkerItem) {
|
|
||||||
idList.add(markerInterface.title)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it.onQsRecordList(idList.distinct().toMutableList())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onItemLongPress(
|
|
||||||
list: MutableList<Int>?,
|
|
||||||
nearest: Int
|
|
||||||
): Boolean {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
addLayer(itemizedLayer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
|
|
||||||
mContext.lifecycleScope.launch(Dispatchers.IO) {
|
|
||||||
var list = mutableListOf<QsRecordBean>()
|
|
||||||
val realm = Realm.getDefaultInstance()
|
|
||||||
realm.executeTransaction {
|
|
||||||
val objects = realm.where<QsRecordBean>().findAll()
|
|
||||||
list = realm.copyFromRealm(objects)
|
|
||||||
}
|
|
||||||
// realm.close()
|
|
||||||
|
|
||||||
for (item in list) {
|
|
||||||
createMarkerItem(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化定位图层
|
* 初始化定位图层
|
||||||
@ -479,19 +505,19 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
/**
|
/**
|
||||||
* 添加质检数据marker
|
* 添加质检数据marker
|
||||||
*/
|
*/
|
||||||
private suspend fun createNoteMarkerItem(item: NoteBean) {
|
private fun createNoteMarkerItem(item: NoteBean) {
|
||||||
val bitmap: Bitmap = createTextMarkerBitmap(mContext, item.description, noteResId)
|
val bitmap: Bitmap = createTextMarkerBitmap(mContext, item.description, noteResId)
|
||||||
val geometry: Geometry? = GeometryTools.createGeometry(item.guideGeometry)
|
val geometry: Geometry? = GeometryTools.createGeometry(item.guideGeometry)
|
||||||
if (geometry != null) {
|
if (geometry != null) {
|
||||||
var geoPoint: org.oscim.core.GeoPoint? = null
|
var geoPoint: GeoPoint? = null
|
||||||
if (geometry.geometryType != null) {
|
if (geometry.geometryType != null) {
|
||||||
when (geometry.geometryType.uppercase(Locale.getDefault())) {
|
when (geometry.geometryType.uppercase(Locale.getDefault())) {
|
||||||
"POINT" -> geoPoint =
|
"POINT" -> geoPoint =
|
||||||
org.oscim.core.GeoPoint(geometry.coordinate.y, geometry.coordinate.x)
|
GeoPoint(geometry.coordinate.y, geometry.coordinate.x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (geoPoint != null) {
|
if (geoPoint != null) {
|
||||||
var geoMarkerItem: MarkerItem
|
val geoMarkerItem: MarkerItem
|
||||||
geoMarkerItem = ClusterMarkerItem(
|
geoMarkerItem = ClusterMarkerItem(
|
||||||
1, item.id, item.description, geoPoint
|
1, item.id, item.description, geoPoint
|
||||||
)
|
)
|
||||||
@ -509,32 +535,69 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
/**
|
/**
|
||||||
* 添加质检数据marker
|
* 添加质检数据marker
|
||||||
*/
|
*/
|
||||||
private suspend fun createMarkerItem(item: QsRecordBean) {
|
private fun createQsRecordMarker(item: QsRecordBean) {
|
||||||
val bitmap: Bitmap = createTextMarkerBitmap(mContext, item.description, resId)
|
val bitmap: Bitmap = createTextMarkerBitmap(mContext, item.description, resId)
|
||||||
if (item.t_lifecycle != 2) {
|
if (item.t_lifecycle != 2) {
|
||||||
val geometry: Geometry? = GeometryTools.createGeometry(item.geometry)
|
val geometry: Geometry? = GeometryTools.createGeometry(item.geometry)
|
||||||
if (geometry != null) {
|
if (geometry != null) {
|
||||||
var geoPoint: org.oscim.core.GeoPoint? = null
|
var geoPoint: GeoPoint? = null
|
||||||
if (geometry.geometryType != null) {
|
if (geometry.geometryType != null) {
|
||||||
when (geometry.geometryType.uppercase(Locale.getDefault())) {
|
when (geometry.geometryType.uppercase(Locale.getDefault())) {
|
||||||
"POINT" -> geoPoint =
|
"POINT" -> geoPoint =
|
||||||
|
GeoPoint(geometry.coordinate.y, geometry.coordinate.x)
|
||||||
|
// "LINESTRING" -> {
|
||||||
|
// val lineString = geometry as LineString
|
||||||
|
// if (lineString != null && lineString.coordinates.size > 0) {
|
||||||
|
// geoPoint = GeoPoint(
|
||||||
|
// lineString.coordinates[0].y,
|
||||||
|
// lineString.coordinates[0].x
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// val drawableLine: Drawable =
|
||||||
|
// convertGeometry2Drawable(geometry, lineStyle)
|
||||||
|
// if (drawableLine != null) {
|
||||||
|
// dataVectorLayer.add(drawableLine)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// "POLYGON" -> {
|
||||||
|
// val polygon = geometry as Polygon
|
||||||
|
// if (polygon != null && polygon.coordinates.size > 0) {
|
||||||
|
// geoPoint = GeoPoint(
|
||||||
|
// polygon.coordinates[0].y,
|
||||||
|
// polygon.coordinates[0].x
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// val drawablePolygon: Drawable =
|
||||||
|
// convertGeometry2Drawable(geometry, polygonStyle)
|
||||||
|
// if (drawablePolygon != null) {
|
||||||
|
// dataVectorLayer.add(drawablePolygon)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
org.oscim.core.GeoPoint(geometry.coordinate.y, geometry.coordinate.x)
|
org.oscim.core.GeoPoint(geometry.coordinate.y, geometry.coordinate.x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (geoPoint != null) {
|
if (geoPoint != null) {
|
||||||
var geoMarkerItem: MarkerItem
|
val geoMarkerItem: MarkerItem
|
||||||
// if (item.getType() === 1) {
|
// if (item.getType() === 1) {
|
||||||
geoMarkerItem = ClusterMarkerItem(
|
geoMarkerItem = ClusterMarkerItem(
|
||||||
1, item.id, item.description, geoPoint
|
1, item.id, item.description, geoPoint
|
||||||
)
|
)
|
||||||
|
// } else {
|
||||||
|
// geoMarkerItem = MarkerItem(
|
||||||
|
// ePointTemp.getType(),
|
||||||
|
// ePointTemp.getId(),
|
||||||
|
// ePointTemp.getStyleText(),
|
||||||
|
// geoPoint
|
||||||
|
// )
|
||||||
|
// }
|
||||||
val markerSymbol =
|
val markerSymbol =
|
||||||
MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.CENTER)
|
MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.CENTER)
|
||||||
geoMarkerItem.marker = markerSymbol
|
geoMarkerItem.marker = markerSymbol
|
||||||
itemizedLayer.itemList.add(geoMarkerItem)
|
qsRecordItemizedLayer.itemList.add(geoMarkerItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemizedLayer.populate()
|
qsRecordItemizedLayer.populate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -774,7 +837,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
val originBitmap = android.graphics.Bitmap.createBitmap(
|
val originBitmap = android.graphics.Bitmap.createBitmap(
|
||||||
if (drawable.intrinsicWidth > maxWidth) drawable.intrinsicWidth else maxWidth.toInt(),
|
if (drawable.intrinsicWidth > maxWidth) drawable.intrinsicWidth else maxWidth.toInt(),
|
||||||
drawable.intrinsicHeight * 2,
|
drawable.intrinsicHeight * 2,
|
||||||
android.graphics.Bitmap.Config.ARGB_4444
|
android.graphics.Bitmap.Config.ARGB_8888
|
||||||
)
|
)
|
||||||
val androidCanvas = Canvas(originBitmap)
|
val androidCanvas = Canvas(originBitmap)
|
||||||
val startX = (originBitmap.width - drawable.intrinsicWidth) / 2
|
val startX = (originBitmap.width - drawable.intrinsicWidth) / 2
|
||||||
@ -808,5 +871,4 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
|||||||
interface OnQsRecordItemClickListener {
|
interface OnQsRecordItemClickListener {
|
||||||
fun onQsRecordList(list: MutableList<String>)
|
fun onQsRecordList(list: MutableList<String>)
|
||||||
fun onNoteList(list: MutableList<String>)
|
fun onNoteList(list: MutableList<String>)
|
||||||
fun onNiLocationList(list: MutableList<NiLocation>)
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user