| | |
| | | int progress = (int) (100 * bytesWritten / contentLength); |
| | | // 例如:更新 ProgressBar 或显示进度 |
| | | runOnUiThread(() -> { |
| | | if (progress <5) { |
| | | uplodData.setProgress(0); |
| | | } |
| | | // 进度条更新代码 |
| | | if (adapter != null && uplodData.getAdapterPosition() != -1) { |
| | | //优化不频繁更新进度 |
| | | if (progress - uplodData.getProgress() > 5 || progress == 100){ |
| | | if (progress - uplodData.getProgress() > 5 || progress == 100) { |
| | | uplodData.setProgress(progress); |
| | | adapter.updateProgress(uplodData); |
| | | |
| | | } |
| | | |
| | | } |
| | | MyLog.d("progressRequestBodyHolder>>>path" + "adapterPosition:" + uplodData.getAdapterPosition() + ">>>上传进度: " + progress + "%"); |
| | | }); |