[6.3.0]
[taxi][passenger] [音乐播放]
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user