Browse Source

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

drake 1 year ago
parent
commit
aeef2bf96b
1 changed files with 4 additions and 1 deletions
  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