Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS

This commit is contained in:
xiaoyan 2023-05-06 16:27:40 +08:00
commit 65f4fe548c
3 changed files with 19 additions and 13 deletions

View File

@ -22,6 +22,7 @@ import kotlinx.coroutines.withContext
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
@HiltViewModel @HiltViewModel
class TaskListViewModel @Inject constructor( class TaskListViewModel @Inject constructor(
private val networkService: NetworkService, private val networkService: NetworkService,
@ -30,6 +31,9 @@ class TaskListViewModel @Inject constructor(
val liveDataTaskList = MutableLiveData<List<TaskBean>>() val liveDataTaskList = MutableLiveData<List<TaskBean>>()
val colors =
arrayOf(Color.RED, Color.YELLOW, Color.BLUE, Color.MAGENTA, Color.GREEN, Color.CYAN)
/** /**
* 下载任务列表 * 下载任务列表
*/ */
@ -43,7 +47,8 @@ class TaskListViewModel @Inject constructor(
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
realm.executeTransaction { realm.executeTransaction {
result.data.obj?.let { list -> result.data.obj?.let { list ->
for (task in list) { for (index in list.indices) {
val task = list[index]
val item = realm.where(TaskBean::class.java).equalTo( val item = realm.where(TaskBean::class.java).equalTo(
"id", task.id "id", task.id
).findFirst() ).findFirst()
@ -54,6 +59,9 @@ class TaskListViewModel @Inject constructor(
task.currentSize = item.currentSize task.currentSize = item.currentSize
task.color = item.color task.color = item.color
} else { } else {
if (index < 6)
task.color = colors[index]
else {
val random = Random() val random = Random()
task.color = Color.argb( task.color = Color.argb(
255, 255,
@ -61,7 +69,7 @@ class TaskListViewModel @Inject constructor(
random.nextInt(256), random.nextInt(256),
random.nextInt(256) random.nextInt(256)
) )
Log.e("jingo", "任务颜色 ${task.color}") }
} }
realm.copyToRealmOrUpdate(task) realm.copyToRealmOrUpdate(task)
} }
@ -105,9 +113,6 @@ class TaskListViewModel @Inject constructor(
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList) mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
} }
} }
} }
} }
} }

View File

@ -70,7 +70,7 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
.fillColor(context.resources.getColor(R.color.draw_line_red_color, null)) .fillColor(context.resources.getColor(R.color.draw_line_red_color, null))
.fillAlpha(0.5f) .fillAlpha(0.5f)
.strokeColor(context.resources.getColor(R.color.draw_line_red_color, null)) .strokeColor(context.resources.getColor(R.color.draw_line_red_color, null))
.strokeWidth(4f) .strokeWidth(8f)
.fixed(true).build() .fixed(true).build()
) )
addLayer(omdbTaskLinkLayer, NIMapView.LAYER_GROUPS.VECTOR) addLayer(omdbTaskLinkLayer, NIMapView.LAYER_GROUPS.VECTOR)

View File

@ -31,6 +31,7 @@ class OmdbTaskLinkLayer(map: Map, private var style: Style) : VectorLayer(map) {
hadLinkDvoBeanList.forEach { hadLinkDvoBeanList.forEach {
addLine(it, style) addLine(it, style)
} }
update()
} }
fun removeLine(linkPid: String): Boolean { fun removeLine(linkPid: String): Boolean {