Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
This commit is contained in:
@@ -3,6 +3,7 @@ package com.navinfo.omqs.ui.activity.map
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.AnimationDrawable
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Build
|
||||
@@ -30,6 +31,7 @@ import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.ImportConfig
|
||||
import com.navinfo.omqs.bean.SignBean
|
||||
import com.navinfo.omqs.bean.TaskBean
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.ui.dialog.CommonDialog
|
||||
import com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||
@@ -39,6 +41,7 @@ import com.navinfo.omqs.util.FlowEventBus
|
||||
import com.navinfo.omqs.util.SoundMeter
|
||||
import com.navinfo.omqs.util.SpeakMode
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmSet
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.collect
|
||||
@@ -97,6 +100,36 @@ class MainViewModel @Inject constructor(
|
||||
testPoint = it
|
||||
}
|
||||
}
|
||||
|
||||
initTaskData()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始话任务高亮高亮
|
||||
*/
|
||||
private fun initTaskData() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
viewModelScope.launch {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val results = realm.where(TaskBean::class.java).findAll()
|
||||
val list = realm.copyFromRealm(results)
|
||||
results.addChangeListener { changes ->
|
||||
val list2 = realm.copyFromRealm(changes)
|
||||
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
|
||||
for (item in list2) {
|
||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
|
||||
}
|
||||
}
|
||||
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
|
||||
for (item in list) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
mapController.lineHandler.omdbTaskLinkLayer.setLineColor(Color.valueOf(item.color))
|
||||
}
|
||||
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
|
||||
}
|
||||
}
|
||||
// realm.close()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initLocation() {
|
||||
@@ -163,11 +196,12 @@ class MainViewModel @Inject constructor(
|
||||
signList.add(
|
||||
SignBean(
|
||||
iconId = SignUtil.getSignIcon(element),
|
||||
iconText = SignUtil.getSignText(element),
|
||||
iconText = SignUtil.getSignIconText(element),
|
||||
distance = distance.toInt(),
|
||||
elementId = element.id,
|
||||
linkId = linkId,
|
||||
geometry = element.geometry
|
||||
geometry = element.geometry,
|
||||
bottomText = SignUtil.getSignBottomText(element)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.navinfo.omqs.ui.fragment.tasklist
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -13,9 +14,11 @@ import com.navinfo.omqs.http.taskdownload.TaskDownloadManager
|
||||
import com.navinfo.omqs.http.taskupload.TaskUploadManager
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileDownloadStatus
|
||||
import com.navinfo.omqs.tools.FileManager.Companion.FileUploadStatus
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@@ -56,7 +59,7 @@ class TaskListAdapter(
|
||||
val taskBean = data[it.tag as Int]
|
||||
Log.e("jingo", "开始上传 ${taskBean.syncStatus}")
|
||||
when (taskBean.syncStatus) {
|
||||
FileManager.Companion.FileUploadStatus.NONE->{
|
||||
FileUploadStatus.NONE, FileUploadStatus.ERROR -> {
|
||||
uploadManager.start(taskBean.id)
|
||||
}
|
||||
}
|
||||
@@ -93,6 +96,7 @@ class TaskListAdapter(
|
||||
binding.taskName.text = taskBean.evaluationTaskName
|
||||
binding.taskCityName.text = taskBean.cityName
|
||||
binding.taskDataVersion.text = "版本号:${taskBean.dataVersion}"
|
||||
binding.taskColor.setTextColor(taskBean.color)
|
||||
// binding.offlineMapCitySize.text = cityBean.getFileSizeText()
|
||||
}
|
||||
|
||||
@@ -114,16 +118,16 @@ class TaskListAdapter(
|
||||
|
||||
private fun changeUploadTxtViews(binding: AdapterTaskListBinding, taskBean: TaskBean) {
|
||||
when (taskBean.syncStatus) {
|
||||
FileManager.Companion.FileUploadStatus.DONE -> {
|
||||
FileUploadStatus.DONE -> {
|
||||
binding.taskUploadBtn.text = "已上传"
|
||||
}
|
||||
FileManager.Companion.FileUploadStatus.ERROR -> {
|
||||
FileUploadStatus.ERROR -> {
|
||||
binding.taskUploadBtn.text = "重新同步"
|
||||
}
|
||||
FileManager.Companion.FileUploadStatus.NONE -> {
|
||||
FileUploadStatus.NONE -> {
|
||||
binding.taskUploadBtn.text = "同步"
|
||||
}
|
||||
FileManager.Companion.FileUploadStatus.WAITING -> {
|
||||
FileUploadStatus.WAITING -> {
|
||||
binding.taskUploadBtn.text = "等待同步"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,8 @@ package com.navinfo.omqs.ui.fragment.tasklist
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.graphics.toColor
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
@@ -20,6 +17,7 @@ import io.realm.Realm
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
@@ -30,6 +28,9 @@ class TaskListViewModel @Inject constructor(
|
||||
|
||||
val liveDataTaskList = MutableLiveData<List<TaskBean>>()
|
||||
|
||||
/**
|
||||
* 下载任务列表
|
||||
*/
|
||||
fun getTaskList(context: Context) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
|
||||
@@ -49,6 +50,16 @@ class TaskListViewModel @Inject constructor(
|
||||
Log.e("jingo", "当前文件大小 ${task.fileSize}")
|
||||
task.status = item.status
|
||||
task.currentSize = item.currentSize
|
||||
task.color = item.color
|
||||
} else {
|
||||
val random = Random()
|
||||
task.color = Color.argb(
|
||||
255,
|
||||
random.nextInt(256),
|
||||
random.nextInt(256),
|
||||
random.nextInt(256)
|
||||
)
|
||||
Log.e("jingo", "任务颜色 ${task.color}")
|
||||
}
|
||||
realm.copyToRealmOrUpdate(task)
|
||||
}
|
||||
@@ -76,7 +87,9 @@ class TaskListViewModel @Inject constructor(
|
||||
for (item in taskList) {
|
||||
FileManager.checkOMDBFileInfo(item)
|
||||
}
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.setLineColor(Color.rgb(0, 255, 0).toColor())
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.setLineColor(
|
||||
// Color.rgb(0, 255, 0).toColor()
|
||||
// )
|
||||
// taskList.forEach {
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.addLineList(it.hadLinkDvoList)
|
||||
// }
|
||||
|
||||
@@ -10,7 +10,7 @@ class SignUtil {
|
||||
/**
|
||||
* 获取面板上的文字
|
||||
*/
|
||||
fun getSignText(data: RenderEntity): String {
|
||||
fun getSignIconText(data: RenderEntity): String {
|
||||
return when (data.code) {
|
||||
//常规点限速
|
||||
4002 -> getSpeedLimitText(data)
|
||||
@@ -24,14 +24,28 @@ class SignUtil {
|
||||
}
|
||||
}
|
||||
|
||||
fun getSignBottomText(data: RenderEntity): String {
|
||||
return when (data.code) {
|
||||
//常规点限速
|
||||
4002 -> "常规点限速"
|
||||
//道路种别
|
||||
2008 -> "道路种别"
|
||||
//道路方向
|
||||
2010 -> "道路方向"
|
||||
//车道数
|
||||
2041 -> "车道数"
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取限速值文字
|
||||
*/
|
||||
private fun getSpeedLimitText(data: RenderEntity): String {
|
||||
try {
|
||||
//限速标志 0 限速开始 1 限速解除
|
||||
val maxSpeed = data.properties["max_speed"]
|
||||
val minSpeed = data.properties["min_speed"]
|
||||
val maxSpeed = data.properties["maxSpeed"]
|
||||
val minSpeed = data.properties["minSpeed"]
|
||||
return if (maxSpeed != "0")
|
||||
maxSpeed.toString()
|
||||
else
|
||||
@@ -48,8 +62,7 @@ class SignUtil {
|
||||
fun getSpeedLimitIcon(data: RenderEntity): Int {
|
||||
try {
|
||||
//限速标志 0 限速开始 1 限速解除
|
||||
val speedFlag = data.properties["speed_flag"]
|
||||
return when (speedFlag) {
|
||||
return when (data.properties["speed_flag"]) {
|
||||
"1" -> return R.drawable.icon_speed_limit_off
|
||||
else -> return R.drawable.icon_speed_limit
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user