소스 검색

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