Open ZQ-BB opened 2 years ago
当我使用 setProgressCallback 对put设置进度监听,但是没有正常返回进度 代码如下:
put.progressCallback = OSSProgressCallback { _, currentSize, totalSize -> receiverLengthLiveData.postValue(currentSize) progressLiveData.postValue((currentSize * 100F / totalSize).toInt()) }
这边设置了livedata 进行监听
while (coroutineScope.isActive) { receiverLengthLiveData.value?.let { val speed = (it - prevLength) * 2 / 1024 setProgress( workDataOf( SPEED to speed, PROGRESS to progressLiveData.value ) ) prevLength = it println("speed=$speed, progress=${progressLiveData.value} ") } delay(500) }
每0.5秒获取一次,完成后取消
但是实际显示 2022-05-16 16:39:02.307 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=0 2022-05-16 16:39:02.831 30817-30862/com.zykj.download.test I/System.out: speed=1233, progress=100 2022-05-16 16:39:03.346 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:03.860 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:04.374 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:04.890 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:05.403 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:05.916 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:06.428 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:06.944 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100
在一开始虽然显示速度1233kb/s且已完成,但是并没有取消,通过抓包发现还是有上传连接,希望能修复这个问题
当我使用 setProgressCallback 对put设置进度监听,但是没有正常返回进度 代码如下:
这边设置了livedata 进行监听
每0.5秒获取一次,完成后取消
但是实际显示 2022-05-16 16:39:02.307 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=0 2022-05-16 16:39:02.831 30817-30862/com.zykj.download.test I/System.out: speed=1233, progress=100 2022-05-16 16:39:03.346 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:03.860 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:04.374 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:04.890 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:05.403 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:05.916 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:06.428 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100 2022-05-16 16:39:06.944 30817-30862/com.zykj.download.test I/System.out: speed=0, progress=100
在一开始虽然显示速度1233kb/s且已完成,但是并没有取消,通过抓包发现还是有上传连接,希望能修复这个问题