[taxi][passenger]
[音乐播放]
This commit is contained in:
yangyakun
2024-03-06 19:25:52 +08:00
parent 29913b6eee
commit 6d2deed800
36 changed files with 1842 additions and 250 deletions

View File

@@ -56,4 +56,32 @@ object DownloadUtils {
}
.launchIn(scope)
}
fun downLoadNoUi(ctx: Context?, url: String, savePath: String, fileName: String, listener: IDownloadListener?) { // FileBean fileBean = new FileBean(0, savePath, fileName, url, 0);
val context = ctx ?: Utils.getApp() ?: throw AssertionError("context must not be null.")
if (!Downloader.hasInit()) {
Downloader.init(context)
Downloader.setLoggable(BuildConfig.DEBUG)
}
Downloader.setNetStatePoller(poller)
Downloader.download(url, File(savePath, fileName))
.onEach {
when(it) {
is DownloadStart ->
UiThreadHandler.post { listener?.onStart(url) }
is Downloading -> {
UiThreadHandler.post { listener?.onProgress(url, it.downloaded, it.total) }
}
is DownloadSuccess -> {
UiThreadHandler.post { listener?.onFinished(url, it.path)}
}
is DownloadFailed -> {
UiThreadHandler.post { listener?.onError(url, it.msg) }
}
}
}
.filter {
it.isComplete()
}
.launchIn(scope)
}
}