修改下载没有回调bug,添加下载完成自动安装
This commit is contained in:
@@ -39,6 +39,8 @@ public class DownloadService implements InitThread.InitCallBack, DownloadCallBac
|
||||
private final Map<String, IDownload> callBacks = new ConcurrentHashMap<>();
|
||||
public static ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
|
||||
private IDownload mIDownload = null;
|
||||
|
||||
private DownloadService(Context context) {
|
||||
mContext = context;
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
@@ -56,6 +58,8 @@ public class DownloadService implements InitThread.InitCallBack, DownloadCallBac
|
||||
}
|
||||
|
||||
public synchronized void onStartCommand(Intent intent, IDownload iDownload) {
|
||||
mIDownload = iDownload;
|
||||
|
||||
if (intent == null) {
|
||||
Log.e(DOWN_LOAD_TAG, "onStartCommand intent is null");
|
||||
return;
|
||||
@@ -124,6 +128,8 @@ public class DownloadService implements InitThread.InitCallBack, DownloadCallBac
|
||||
|
||||
@Override
|
||||
public void startDownload(String url) {
|
||||
callBacks.put(url, mIDownload);
|
||||
|
||||
IDownload iDownload = callBacks.get(url);
|
||||
if (iDownload != null) {
|
||||
iDownload.onStart(url);
|
||||
@@ -148,8 +154,11 @@ public class DownloadService implements InitThread.InitCallBack, DownloadCallBac
|
||||
|
||||
@Override
|
||||
public void threadDownLoadFinished(String url, ThreadBean threadBean) {
|
||||
Log.e(DOWN_LOAD_TAG, "threadDownLoadFinished 1 : " + url);
|
||||
IDownload iDownload = callBacks.get(url);
|
||||
Log.d(DOWN_LOAD_TAG, "iDownload = " + iDownload);
|
||||
if (iDownload != null) {
|
||||
Log.e(DOWN_LOAD_TAG, "threadDownLoadFinished 2 : " + url);
|
||||
iDownload.onFinished(url, threadBean);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ public class DownloadTask implements DownloadCallBack {
|
||||
}
|
||||
}
|
||||
if (threads.size() == 0) {//如果列表size为0 则所有线程已下载完成
|
||||
Log.d(DOWN_LOAD_TAG, "下载完成----->");
|
||||
//删除数据库中的信息
|
||||
dao.deleteThread(fileBean.getUrl());
|
||||
//发送下载完成事件
|
||||
|
||||
Reference in New Issue
Block a user