Skip to content

Commit

Permalink
feature: 下载进度回调再主线程中进行
Browse files Browse the repository at this point in the history
  • Loading branch information
tangwanchao committed Feb 2, 2023
1 parent d28e015 commit 29a00b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion download/src/main/java/me/twc/source/download/Downloader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class Downloader(
while (bytes >= 0) {
fos.write(buffer, 0, bytes)
downloadLength += bytes
callback.onDownload(downloadLength, totalLength)
withContext(Dispatchers.Main){
callback.onDownload(downloadLength, totalLength)
}
bytes = bs.read(buffer)
}
} catch (th: Throwable) {
Expand Down

0 comments on commit 29a00b3

Please sign in to comment.