修改任务下载

This commit is contained in:
squallzhjch
2023-07-27 11:16:36 +08:00
parent 01bc6ac7fc
commit 2b4b2645a6
5 changed files with 30 additions and 5 deletions

View File

@@ -83,6 +83,12 @@ class TaskDownloadManager constructor(
* 只有等待中的任务和正在下载中的任务才可以进行暂停操作 * 只有等待中的任务和正在下载中的任务才可以进行暂停操作
*/ */
fun pause(id: Int) { fun pause(id: Int) {
if (scopeMap.containsKey(id)) {
val downloadScope = scopeMap[id]
downloadScope?.let {
downloadScope.pause()
}
}
if (taskScopeMap.containsKey(id)) { if (taskScopeMap.containsKey(id)) {
val downloadScope = taskScopeMap[id] val downloadScope = taskScopeMap[id]
downloadScope?.let { downloadScope?.let {

View File

@@ -60,7 +60,11 @@ class TaskDownloadScope(
fun pause() { fun pause() {
downloadJob?.cancel("pause") downloadJob?.cancel("pause")
launch { launch {
change(FileDownloadStatus.PAUSE) if (taskBean.fileSize == 0L) {
change(FileDownloadStatus.NONE)
} else {
change(FileDownloadStatus.PAUSE)
}
} }
} }
@@ -123,7 +127,7 @@ class TaskDownloadScope(
/** /**
* 导入数据 * 导入数据
*/ */
private suspend fun importData(file: File? = null, taskId: Int?=0) { private suspend fun importData(file: File? = null, taskId: Int? = 0) {
try { try {
Log.e("jingo", "importData SSS") Log.e("jingo", "importData SSS")
change(FileDownloadStatus.IMPORTING) change(FileDownloadStatus.IMPORTING)
@@ -135,7 +139,7 @@ class TaskDownloadScope(
fileNew fileNew
) )
if (taskId != null) { if (taskId != null) {
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile,taskId).collect { importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, taskId).collect {
Log.e("jingo", "数据安装 $it") Log.e("jingo", "数据安装 $it")
if (it == "finish") { if (it == "finish") {
change(FileDownloadStatus.DONE) change(FileDownloadStatus.DONE)
@@ -183,7 +187,7 @@ class TaskDownloadScope(
startPosition = 0 startPosition = 0
} }
if (fileTemp.length() > 0 && taskBean.fileSize > 0 && fileTemp.length() == taskBean.fileSize) { if (fileTemp.length() > 0 && taskBean.fileSize > 0 && fileTemp.length() == taskBean.fileSize) {
importData(fileTemp,taskBean.id) importData(fileTemp, taskBean.id)
return return
} }

View File

@@ -449,7 +449,7 @@ class MainViewModel @Inject constructor(
) )
if(itemList.size == 1){ if(itemList.size == 1){
SignUtil.getSignNameText(itemList[0])
} }
} }
} }

View File

@@ -306,7 +306,11 @@ class TaskListAdapter(
binding.taskProgressText.text = binding.taskProgressText.text =
"$progress%" "$progress%"
binding.taskDownloadBtn.setProgress(progress) binding.taskDownloadBtn.setProgress(progress)
} else {
binding.taskDownloadBtn.setProgress(0)
binding.taskProgressText.text = ""
} }
when (taskBean.status) { when (taskBean.status) {
FileDownloadStatus.NONE -> { FileDownloadStatus.NONE -> {
if (binding.taskProgressText.visibility == View.VISIBLE) binding.taskProgressText.visibility = if (binding.taskProgressText.visibility == View.VISIBLE) binding.taskProgressText.visibility =

View File

@@ -80,6 +80,8 @@ class SignUtil {
2008 -> "种别" 2008 -> "种别"
//道路方向 //道路方向
2010 -> "方向" 2010 -> "方向"
//车道边界类型
2013 -> "车道边界类型"
//常规线限速 //常规线限速
2019 -> "线限速" 2019 -> "线限速"
//车道数 //车道数
@@ -404,7 +406,16 @@ class SignUtil {
return stringBuffer.toString() return stringBuffer.toString()
} }
/**
* 获取车道边界线详细信息
*/
fun getLaneBoundaryInfo(data:RenderEntity){
}
/**
* 获取道路名列表
*/
fun getRoadNameList(data: RenderEntity): MutableList<RoadNameBean> { fun getRoadNameList(data: RenderEntity): MutableList<RoadNameBean> {
val list = mutableListOf<RoadNameBean>() val list = mutableListOf<RoadNameBean>()
if (data.code == 2011) { if (data.code == 2011) {