2.12.0 优化了下载进度,添加通知栏的下载进度条

This commit is contained in:
lixiaopeng
2022-11-10 16:15:21 +08:00
parent 8adfa6a16c
commit cb763366fc
5 changed files with 106 additions and 16 deletions

View File

@@ -155,7 +155,6 @@ public class DownloadService implements InitThread.InitCallBack, DownloadCallBac
@Override
public void threadDownLoadFinished(String url, ThreadBean threadBean) {
IDownload iDownload = callBacks.get(url);
Log.d(DOWN_LOAD_TAG, "iDownload threadDownLoadFinished = " + iDownload);
if (iDownload != null) {
iDownload.onFinished(url, threadBean);
}

View File

@@ -119,7 +119,7 @@ public class DownloadTask implements DownloadCallBack {
//每500毫秒发送刷新进度事件
if (System.currentTimeMillis() - curTime > 500 || finishedProgress == fileBean.getLength()) {
int progress = (int) (finishedProgress * 1.0 / fileBean.getLength() * 100);
Log.d(DOWN_LOAD_TAG, "length = $length ----- progress = progress");
// Log.d(DOWN_LOAD_TAG, "DownloadTask ----length = " + length + " ---progress = " + progress);
fileBean.setFinished(finishedProgress);
DownloadData downloadData = new DownloadData();
downloadData.setUrl(fileBean.getUrl());
@@ -143,7 +143,7 @@ public class DownloadTask implements DownloadCallBack {
}
}
if (threads.size() == 0) {//如果列表size为0 则所有线程已下载完成
Log.d(DOWN_LOAD_TAG, "下载完成----->");
Log.d(DOWN_LOAD_TAG, " DownloadTask threadDownLoadFinished 下载完成----->");
//删除数据库中的信息
dao.deleteThread(fileBean.getUrl());
//发送下载完成事件