コード例 #1
0
 private void init() {
   mDownloadInfo =
       new DownloadInfo(
           mRequest.getTitle().toString(),
           mRequest.getUri(),
           mRequest.getFolder(),
           mRequest.getHeaders());
   mDownloadTasks = new LinkedList<>();
 }
コード例 #2
0
 // TODO
 private List<ThreadInfo> getMultiThreadInfos(long length) {
   // init threadInfo from db
   final List<ThreadInfo> threadInfos = mDBManager.getThreadInfos(mTag);
   if (threadInfos.isEmpty()) {
     final int threadNum = mConfig.getThreadNum();
     for (int i = 0; i < threadNum; i++) {
       // calculate average
       final long average = length / threadNum;
       final long start = average * i;
       final long end;
       if (i == threadNum - 1) {
         end = length;
       } else {
         end = start + average - 1;
       }
       ThreadInfo threadInfo = new ThreadInfo(i, mTag, mRequest.getUri(), start, end, 0);
       threadInfos.add(threadInfo);
     }
   }
   return threadInfos;
 }
コード例 #3
0
 // TODO
 private ThreadInfo getSingleThreadInfo() {
   ThreadInfo threadInfo = new ThreadInfo(0, mTag, mRequest.getUri(), 0);
   return threadInfo;
 }
コード例 #4
0
 private void connect() {
   mConnectTask = new ConnectTaskImpl(mRequest.getUri(), mRequest.getHeaders(), this);
   mExecutor.execute(mConnectTask);
 }