This commit is contained in:
qiji4215 2023-05-06 16:24:01 +08:00
commit 6840e4d965
10 changed files with 37 additions and 30 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,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)
} }
} }
} }
} }
} }

View File

@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"> <item android:state_enabled="false">
<shape> <shape>
<padding android:bottom="@dimen/default_widget_padding" android:left="@dimen/default_widget_padding" android:right="@dimen/default_widget_padding" android:top="@dimen/default_widget_padding"></padding> <padding android:bottom="2dp" android:left="@dimen/default_widget_padding" android:right="@dimen/default_widget_padding" android:top="2dp"></padding>
<solid android:color="@color/cv_gray_153" /> <solid android:color="@color/cv_gray_153" />
<corners android:radius="@dimen/default_btn_corner"></corners> <corners android:radius="@dimen/default_btn_corner"></corners>
<stroke android:width="1.1dp" android:color="@color/cv_gray_153" /> <stroke android:width="1.1dp" android:color="@color/cv_gray_153" />
@ -10,7 +10,7 @@
</item> </item>
<item android:state_pressed="true"> <item android:state_pressed="true">
<shape> <shape>
<padding android:bottom="@dimen/default_widget_padding" android:left="@dimen/default_widget_padding" android:right="@dimen/default_widget_padding" android:top="@dimen/default_widget_padding"></padding> <padding android:bottom="2dp" android:left="@dimen/default_widget_padding" android:right="@dimen/default_widget_padding" android:top="2dp"></padding>
<solid android:color="@color/white" /> <solid android:color="@color/white" />
<corners android:radius="@dimen/default_btn_corner"></corners> <corners android:radius="@dimen/default_btn_corner"></corners>
<stroke android:width="1.1dp" android:color="@color/colorSecondary" /> <stroke android:width="1.1dp" android:color="@color/colorSecondary" />
@ -18,7 +18,7 @@
</item> </item>
<item android:state_checked="true"> <item android:state_checked="true">
<shape> <shape>
<padding android:bottom="@dimen/default_widget_padding" android:left="@dimen/default_widget_padding" android:right="@dimen/default_widget_padding" android:top="@dimen/default_widget_padding"></padding> <padding android:bottom="2dp" android:left="@dimen/default_widget_padding" android:right="@dimen/default_widget_padding" android:top="2dp"></padding>
<solid android:color="@color/white" /> <solid android:color="@color/white" />
<corners android:radius="@dimen/default_btn_corner"></corners> <corners android:radius="@dimen/default_btn_corner"></corners>
<stroke android:width="1.1dp" android:color="@color/colorSecondary" /> <stroke android:width="1.1dp" android:color="@color/colorSecondary" />
@ -26,7 +26,7 @@
</item> </item>
<item android:state_selected="true"> <item android:state_selected="true">
<shape> <shape>
<padding android:bottom="@dimen/default_widget_padding" android:left="@dimen/default_widget_padding" android:right="@dimen/default_widget_padding" android:top="@dimen/default_widget_padding"></padding> <padding android:bottom="2dp" android:left="@dimen/default_widget_padding" android:right="@dimen/default_widget_padding" android:top="2dp"></padding>
<solid android:color="@color/cvm_red" /> <solid android:color="@color/cvm_red" />
<corners android:radius="@dimen/default_btn_corner"></corners> <corners android:radius="@dimen/default_btn_corner"></corners>
<stroke android:width="1.1dp" android:color="@color/cvm_red" /> <stroke android:width="1.1dp" android:color="@color/cvm_red" />

View File

@ -15,9 +15,11 @@
android:id="@+id/task_name" android:id="@+id/task_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="5dp" android:layout_toLeftOf="@id/task_download_btn"
android:text="任务名称" android:text="任务名称"
android:textSize="12sp" /> android:textStyle="bold"
android:textColor="@color/black"
android:textSize="@dimen/default_font_size" />
<TextView <TextView
android:id="@+id/task_city_name" android:id="@+id/task_city_name"
@ -35,10 +37,10 @@
style="@style/map_size_font_style" style="@style/map_size_font_style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_below="@id/task_city_name"
android:layout_toLeftOf="@id/task_upload_btn"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_toLeftOf="@id/task_upload_btn"
android:layout_below="@id/task_city_name"
android:textColor="@color/gray_121"
android:text="版本号" android:text="版本号"
android:textSize="@dimen/card_title_font_3size" /> android:textSize="@dimen/card_title_font_3size" />
@ -49,6 +51,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/task_data_version" android:layout_below="@id/task_data_version"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:drawableLeft="@mipmap/point_blue"
android:text="路线颜色" android:text="路线颜色"
android:textSize="@dimen/card_title_font_3size" /> android:textSize="@dimen/card_title_font_3size" />
@ -62,7 +65,6 @@
android:gravity="center" android:gravity="center"
android:shadowColor="@android:color/transparent" android:shadowColor="@android:color/transparent"
android:text="下载" android:text="下载"
android:textColor="@color/btn_blue_solid"
android:textSize="@dimen/card_title_font_2size" /> android:textSize="@dimen/card_title_font_2size" />
<TextView <TextView
@ -76,7 +78,6 @@
android:gravity="center" android:gravity="center"
android:shadowColor="@android:color/transparent" android:shadowColor="@android:color/transparent"
android:text="同步" android:text="同步"
android:textColor="@color/btn_blue_solid"
android:textSize="@dimen/card_title_font_2size" /> android:textSize="@dimen/card_title_font_2size" />
<TextView <TextView

View File

@ -30,7 +30,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="@dimen/left_pannel_title_font" android:textSize="@dimen/left_pannel_title_font"
android:textStyle="bold" android:textColor="@color/highFontColor"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"

View File

@ -31,8 +31,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="@dimen/left_pannel_title_font" android:textSize="@dimen/left_pannel_title_font"
android:textStyle="bold"
android:text="离线地图" android:text="离线地图"
android:textColor="@color/highFontColor"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"

View File

@ -31,8 +31,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="@dimen/left_pannel_title_font" android:textSize="@dimen/left_pannel_title_font"
android:textStyle="bold"
android:text="任务列表" android:text="任务列表"
android:textColor="@color/highFontColor"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"

View File

@ -6,7 +6,7 @@
<dimen name="nav_header_vertical_spacing">8dp</dimen> <dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen> <dimen name="nav_header_height">176dp</dimen>
<dimen name="default_widget_padding">10dp</dimen> <dimen name="default_widget_padding">10dp</dimen>
<dimen name="left_pannel_title_font" comment="左侧弹出框顶部标题字体大小">22sp</dimen> <dimen name="left_pannel_title_font" comment="左侧弹出框顶部标题字体大小">20sp</dimen>
<dimen name="default_font_size" comment="默认字体大小style中父最顶层">15sp</dimen> <dimen name="default_font_size" comment="默认字体大小style中父最顶层">15sp</dimen>
<dimen name="card_title_font_size">24sp</dimen> <dimen name="card_title_font_size">24sp</dimen>
<dimen name="card_title_font_2size">13sp</dimen> <dimen name="card_title_font_2size">13sp</dimen>
@ -37,5 +37,5 @@
<!-- 相机设置窗体IV高度--> <!-- 相机设置窗体IV高度-->
<dimen name="camear_dialog_iv_hight" comment="相机设置窗体高度">75dp</dimen> <dimen name="camear_dialog_iv_hight" comment="相机设置窗体高度">75dp</dimen>
<dimen name="head_img_width">48dp</dimen> <dimen name="head_img_width">48dp</dimen>
<dimen name="default_btn_corner">6dp</dimen> <dimen name="default_btn_corner">36dp</dimen>
</resources> </resources>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" map-background="#fffcfa" <rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" map-background="#f4f4f4"
version="1" xmlns="http://opensciencemap.org/rendertheme" version="1" xmlns="http://opensciencemap.org/rendertheme"
xsi:schemaLocation="http://opensciencemap.org/rendertheme xsi:schemaLocation="http://opensciencemap.org/rendertheme
https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd"> https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd">

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 {