修改任务线颜色
This commit is contained in:
parent
8e4d1c7e0e
commit
51be5bd178
@ -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,14 +59,17 @@ class TaskListViewModel @Inject constructor(
|
|||||||
task.currentSize = item.currentSize
|
task.currentSize = item.currentSize
|
||||||
task.color = item.color
|
task.color = item.color
|
||||||
} else {
|
} else {
|
||||||
val random = Random()
|
if (index < 6)
|
||||||
task.color = Color.argb(
|
task.color = colors[index]
|
||||||
255,
|
else {
|
||||||
random.nextInt(256),
|
val random = Random()
|
||||||
random.nextInt(256),
|
task.color = Color.argb(
|
||||||
random.nextInt(256)
|
255,
|
||||||
)
|
random.nextInt(256),
|
||||||
Log.e("jingo", "任务颜色 ${task.color}")
|
random.nextInt(256),
|
||||||
|
random.nextInt(256)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user