From fa4f647a2609a043619f67348712af3be647c2a1 Mon Sep 17 00:00:00 2001 From: sock_magic Date: Tue, 27 Feb 2024 19:37:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=BF=E6=8D=A2=E6=88=90?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bilibilias/base/utils/DownloadQueue.kt | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/imcys/bilibilias/base/utils/DownloadQueue.kt b/app/src/main/java/com/imcys/bilibilias/base/utils/DownloadQueue.kt index d55a81584..4a2b24324 100644 --- a/app/src/main/java/com/imcys/bilibilias/base/utils/DownloadQueue.kt +++ b/app/src/main/java/com/imcys/bilibilias/base/utils/DownloadQueue.kt @@ -420,38 +420,36 @@ class DownloadQueue @Inject constructor() : false, ) - val taskMutableList = groupTasksMap[cid] + val taskMutableList = groupTasksMap[cid]!! val videoTask = - taskMutableList?.filter { it.fileType == 0 } + taskMutableList.single { it.fileType == 0 } val audioTask = - taskMutableList?.filter { it.fileType == 1 } + taskMutableList.single { it.fileType == 1 } if (mergeState) { // 耗时操作,这里直接开个新线程 - val videoPath = - videoTask!![0].savePath - val audioPath = - audioTask!![0].savePath + val videoPath = videoTask.savePath + val audioPath = audioTask.savePath // 这里的延迟是为了有足够时间让下载检查下载完整 runFFmpegRxJavaVideoMerge( - videoTask[0], + videoTask, videoPath, audioPath, ) // 旧的合并方案: MediaExtractorUtils.combineTwoVideos(audioPath, 0,videoPath,mergeFile) } else if (importState) { - videoTask!![0].downloadTaskDataBean.bangumiSeasonBean?.apply { + videoTask.downloadTaskDataBean.bangumiSeasonBean?.apply { // 分别添加下载完成了 - saveFinishTask(videoTask[0], audioTask!![0]) + saveFinishTask(videoTask, audioTask) importVideo(cid) } } else { // 这类代表虽然是dash下载,但是并不需要其他操作 - saveFinishTask(videoTask!![0], audioTask!![0]) + saveFinishTask(videoTask, audioTask) // 这类通知相册更新下文件 - updatePhotoMedias(App.context, File(videoTask[0].savePath), File(audioTask[0].savePath)) + updatePhotoMedias(App.context, File(videoTask.savePath), File(audioTask.savePath)) } }