@Override public void onConnected(long time, long length, boolean isAcceptRanges) { mStatus = DownloadStatus.STATUS_CONNECTED; mResponse.onConnected(time, length, isAcceptRanges); mDownloadInfo.setAcceptRanges(isAcceptRanges); mDownloadInfo.setLength(length); download(length, isAcceptRanges); }
// TODO private void initDownloadTasks(long length, boolean acceptRanges) { mDownloadTasks.clear(); if (acceptRanges) { List<ThreadInfo> threadInfos = getMultiThreadInfos(length); // init finished int finished = 0; for (ThreadInfo threadInfo : threadInfos) { finished += threadInfo.getFinished(); } mDownloadInfo.setFinished(finished); for (ThreadInfo info : threadInfos) { mDownloadTasks.add(new MultiDownloadTask(mDownloadInfo, info, mDBManager, this)); } } else { ThreadInfo info = getSingleThreadInfo(); mDownloadTasks.add(new SingleDownloadTask(mDownloadInfo, info, this)); } }