|
|
@ -262,9 +262,8 @@ public abstract class AbsGroupUtil implements IUtil { |
|
|
|
dt.stop(); |
|
|
|
dt.stop(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (mDownloaderMap.size() == 0) { |
|
|
|
clearState(); |
|
|
|
mListener.onStop(mCurrentLocation); |
|
|
|
mListener.onStop(mCurrentLocation); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void onStop() { |
|
|
|
protected void onStop() { |
|
|
@ -279,7 +278,7 @@ public abstract class AbsGroupUtil implements IUtil { |
|
|
|
mListener.onPre(); |
|
|
|
mListener.onPre(); |
|
|
|
mGroupSize = mGTEntity.getSubTaskEntities().size(); |
|
|
|
mGroupSize = mGTEntity.getSubTaskEntities().size(); |
|
|
|
mTotalLen = mGTEntity.getEntity().getFileSize(); |
|
|
|
mTotalLen = mGTEntity.getEntity().getFileSize(); |
|
|
|
isNeedLoadFileSize = mTotalLen <= 1; |
|
|
|
isNeedLoadFileSize = mTotalLen <= 10; |
|
|
|
for (DownloadTaskEntity te : mGTEntity.getSubTaskEntities()) { |
|
|
|
for (DownloadTaskEntity te : mGTEntity.getSubTaskEntities()) { |
|
|
|
File file = new File(te.getKey()); |
|
|
|
File file = new File(te.getKey()); |
|
|
|
if (te.getState() == IEntity.STATE_COMPLETE && file.exists()) { |
|
|
|
if (te.getState() == IEntity.STATE_COMPLETE && file.exists()) { |
|
|
@ -455,7 +454,7 @@ public abstract class AbsGroupUtil implements IUtil { |
|
|
|
mListener.onSubStop(subEntity); |
|
|
|
mListener.onSubStop(subEntity); |
|
|
|
synchronized (AbsGroupUtil.LOCK) { |
|
|
|
synchronized (AbsGroupUtil.LOCK) { |
|
|
|
mStopNum++; |
|
|
|
mStopNum++; |
|
|
|
if (mStopNum + mCompleteNum + mFailMap.size() == mGroupSize) { |
|
|
|
if (mStopNum + mCompleteNum + mFailMap.size() == mGroupSize && !isStop) { |
|
|
|
closeTimer(false); |
|
|
|
closeTimer(false); |
|
|
|
mListener.onStop(mCurrentLocation); |
|
|
|
mListener.onStop(mCurrentLocation); |
|
|
|
} |
|
|
|
} |
|
|
@ -479,7 +478,9 @@ public abstract class AbsGroupUtil implements IUtil { |
|
|
|
if (mCompleteNum == mGroupSize) { |
|
|
|
if (mCompleteNum == mGroupSize) { |
|
|
|
closeTimer(false); |
|
|
|
closeTimer(false); |
|
|
|
mListener.onComplete(); |
|
|
|
mListener.onComplete(); |
|
|
|
} else if (mFailMap.size() > 0 && mStopNum + mCompleteNum + mFailMap.size() >= mGroupSize) { |
|
|
|
} else if (mFailMap.size() > 0 |
|
|
|
|
|
|
|
&& mStopNum + mCompleteNum + mFailMap.size() >= mGroupSize |
|
|
|
|
|
|
|
&& !isStop) { |
|
|
|
//如果子任务完成数量加上失败的数量和总任务数一致,则任务组停止下载
|
|
|
|
//如果子任务完成数量加上失败的数量和总任务数一致,则任务组停止下载
|
|
|
|
closeTimer(false); |
|
|
|
closeTimer(false); |
|
|
|
mListener.onStop(mCurrentLocation); |
|
|
|
mListener.onStop(mCurrentLocation); |
|
|
@ -500,10 +501,10 @@ public abstract class AbsGroupUtil implements IUtil { |
|
|
|
private void reTry(boolean needRetry) { |
|
|
|
private void reTry(boolean needRetry) { |
|
|
|
Downloader dt = mDownloaderMap.get(subEntity.getUrl()); |
|
|
|
Downloader dt = mDownloaderMap.get(subEntity.getUrl()); |
|
|
|
synchronized (AbsGroupUtil.LOCK) { |
|
|
|
synchronized (AbsGroupUtil.LOCK) { |
|
|
|
if (dt != null |
|
|
|
if (!isCancel && !isStop && dt != null |
|
|
|
&& !dt.isBreak() |
|
|
|
&& !dt.isBreak() |
|
|
|
&& needRetry |
|
|
|
&& needRetry |
|
|
|
&& subEntity.getFailNum() < 5 |
|
|
|
&& subEntity.getFailNum() < 3 |
|
|
|
&& (NetUtils.isConnected(AriaManager.APP) || isNotNetRetry)) { |
|
|
|
&& (NetUtils.isConnected(AriaManager.APP) || isNotNetRetry)) { |
|
|
|
reStartTask(dt); |
|
|
|
reStartTask(dt); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -533,7 +534,7 @@ public abstract class AbsGroupUtil implements IUtil { |
|
|
|
dt.retryThreadTask(); |
|
|
|
dt.retryThreadTask(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, 3000); |
|
|
|
}, 5000); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void handleSpeed(long speed) { |
|
|
|
private void handleSpeed(long speed) { |
|
|
|