浏览代码

fix: #187 上传进度监听finish字段无效

drake 1 年之前
父节点
当前提交
aeef2bf96b
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      net/src/main/java/com/drake/net/body/NetRequestBody.kt

+ 4 - 1
net/src/main/java/com/drake/net/body/NetRequestBody.kt

@@ -84,7 +84,10 @@ class NetRequestBody(
                 progressListeners.forEach { progressListener ->
                     progressListener.intervalByteCount += byteCount
                     val currentInterval = currentElapsedTime - progressListener.elapsedTime
-                    if (currentInterval >= progressListener.interval || writeByteCount == contentLength) {
+                    if (!progress.finish && (writeByteCount == contentLength || currentInterval >= progressListener.interval)) {
+                        if (writeByteCount == contentLength) {
+                            progress.finish = true
+                        }
                         progressListener.onProgress(
                             progress.apply {
                                 currentByteCount = writeByteCount