Java Code Examples for com.liulishuo.filedownloader.util.FileDownloadUtils

The following examples show how to use com.liulishuo.filedownloader.util.FileDownloadUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: YCAudioPlayer   Source File: TasksManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 将某个链接资源添加到下载的队列中
 * @param url               资源url
 * @param path              路径
 * @return                  model
 */
public TasksManagerModel addTask(final String url, final String path) {
    if (TextUtils.isEmpty(url) || TextUtils.isEmpty(path)) {
        return null;
    }
    //根据链接和地址查找对应id
    final int id = FileDownloadUtils.generateId(url, path);
    TasksManagerModel model = getById(id);
    if (model != null) {
        return model;
    }
    //天机到数据库
    final TasksManagerModel newModel = dbController.addTask(url, path);
    if (newModel != null) {
        modelList.add(newModel);
    }
    return newModel;
}
 
Example 2
Source Project: YCAudioPlayer   Source File: TasksManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 将文件音视频内容添加到数据库中
 * @param model                 model
 */
public void addDownloadedDb(DialogListBean model) {
    String url = model.getVideo();
    String path = TasksManager.getImpl().createPath(url);
    if (TextUtils.isEmpty(url) || TextUtils.isEmpty(path)) {
        return ;
    }
    final int id = FileDownloadUtils.generateId(url, path);
    TasksManagerModel bean = new TasksManagerModel();
    bean.setId(id);
    bean.setName(model.getName());
    bean.setUrl(url);
    bean.setUrl(path);
    modelListed.add(bean);
    dbController.addDownloadedDb(bean);
}
 
Example 3
Source Project: YCAudioPlayer   Source File: TasksUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 删除所有数据库中的下载内容信息
 */
public static void deleteAll(){
    File file = new File(FileDownloadUtils.getDefaultSaveRootPath());
    if (!file.exists()) {
        AppLogUtils.e(String.format("check file files not exists %s", file.getAbsolutePath()));
        return;
    }
    if (!file.isDirectory()) {
        AppLogUtils.e(String.format("check file files not directory %s", file.getAbsolutePath()));
        return;
    }
    File[] files = file.listFiles();
    if (files == null) {
        return;
    }
    for (File file1 : files) {
        //noinspection ResultOfMethodCallIgnored
        file1.delete();
    }
    if(TasksManager.getImpl().getDownloadedList()!=null){
        TasksManager.getImpl().getDownloadedList().clear();
    }
    if(TasksManager.getImpl().getModelList()!=null){
        TasksManager.getImpl().getModelList().clear();
    }
}
 
Example 4
Source Project: okdownload   Source File: DownloadTaskAdapter.java    License: Apache License 2.0 6 votes vote down vote up
DownloadTask build() {
    if (path == null) {
        path = FileDownloadUtils.getDefaultSaveFilePath(url);
    }
    @NonNull DownloadTask.Builder builder;
    if (pathAsDirectory) {
        builder = new DownloadTask.Builder(url, path, null);
    } else {
        builder = new DownloadTask.Builder(url, new File(path));
    }
    builder.setMinIntervalMillisCallbackProcess(minIntervalMillisCallbackProgress);
    builder.setPassIfAlreadyCompleted(!forceReDownload);
    builder.setWifiRequired(isWifiRequired);
    for (Map.Entry<String, String> entry : headerMap.entrySet()) {
        builder.addHeader(entry.getKey(), entry.getValue());
    }
    builder.setAutoCallbackToUIThread(autoCallbackToUIThread);
    return builder.build();
}
 
Example 5
Source Project: okdownload   Source File: DownloadTaskAdapterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void build_default() {
    final FileDownloadListener mockListener = mock(FileDownloadListener.class);
    final DownloadTaskAdapter taskAdapter = (DownloadTaskAdapter) FileDownloader.getImpl()
            .create("url").setListener(mockListener);
    FileDownloadUtils.setDefaultSaveRootPath("/sdcard");
    taskAdapter.insureAssembleDownloadTask();

    assertThat(taskAdapter.getPath())
            .isEqualTo(FileDownloadUtils.getDefaultSaveFilePath("url"));
    assertThat(taskAdapter.getCallbackProgressMinInterval())
            .isEqualTo(DownloadTaskAdapter.DEFAULT_CALLBACK_PROGRESS_MIN_INTERVAL_MILLIS);
    assertThat(taskAdapter.isSyncCallback()).isFalse();
    assertThat(taskAdapter.isWifiRequired()).isFalse();
    assertThat(taskAdapter.isForceReDownload()).isFalse();
}
 
Example 6
private static void finishTask(Context context, @NonNull DownloadTask entity) {
    boolean complete = FileDownloader.getImpl()
            .getStatus((int) entity.taskId, entity.getFilePath(context)) == FileDownloadStatus.completed;
    if (complete) {
        innerUpdateTaskResult(entity, DownloadTask.RESULT_SUCCEED);
        context.sendBroadcast(
                new Intent(
                        Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
                        Uri.parse(entity.getFilePath(context))
                )
        );
        if (entity.downloadType != DownloadTask.COLLECTION_TYPE) {
            downloadPhotoSuccess(context, entity);
        } else {
            downloadCollectionSuccess(context, entity);
        }
    } else {
        FileDownloadUtils.deleteTempFile(FileDownloadUtils.getTempPath(entity.getFilePath(context)));
        innerUpdateTaskResult(entity, DownloadTask.RESULT_FAILED);
        if (entity.downloadType != DownloadTask.COLLECTION_TYPE) {
            downloadPhotoFailed(context, entity);
        } else {
            downloadCollectionFailed(context, entity);
        }
    }
}
 
Example 7
Source Project: FileDownloader   Source File: SingleTaskTestActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single);

    llsApkFilePath = FileDownloadUtils.getDefaultSaveRootPath() + File.separator + "tmpdir1" + File.separator +
            Constant.LIULISHUO_CONTENT_DISPOSITION_FILENAME;
    llsApkDir = FileDownloadUtils.getDefaultSaveRootPath() + File.separator + "tmpdir1";
    normalTaskFilePath = FileDownloadUtils.getDefaultSaveRootPath() + File.separator + "tmp2";
    chunkedFilePath = FileDownloadUtils.getDefaultSaveRootPath() + File.separator + "chunked_data_tmp1";

    assignViews();

    initFilePathEqualDirAndFileName();
    initNormalDataAction();
    initChunkTransferEncodingDataAction();
}
 
Example 8
Source Project: FileDownloader   Source File: HybridTestActivity.java    License: Apache License 2.0 6 votes vote down vote up
public void onClickDel(final View view) {
    File file = new File(FileDownloadUtils.getDefaultSaveRootPath());
    if (!file.exists()) {
        Log.w(TAG, String.format("check file files not exists %s", file.getAbsolutePath()));
        return;
    }

    if (!file.isDirectory()) {
        Log.w(TAG, String.format("check file files not directory %s", file.getAbsolutePath()));
        return;
    }

    File[] files = file.listFiles();

    if (files == null) {
        updateDisplay(getString(R.string.del_file_error_empty));
        return;
    }

    for (File file1 : files) {
        file1.delete();
        updateDisplay(getString(R.string.hybrid_test_deleted_file, file1.getName()));
    }
}
 
Example 9
Source Project: FileDownloader   Source File: TasksManagerDemoActivity.java    License: Apache License 2.0 6 votes vote down vote up
public TasksManagerModel addTask(final String url, final String path) {
    if (TextUtils.isEmpty(url) || TextUtils.isEmpty(path)) {
        return null;
    }

    final int id = FileDownloadUtils.generateId(url, path);
    TasksManagerModel model = getById(id);
    if (model != null) {
        return model;
    }
    final TasksManagerModel newModel = dbController.addTask(url, path);
    if (newModel != null) {
        modelList.add(newModel);
    }

    return newModel;
}
 
Example 10
Source Project: FileDownloader   Source File: TasksManagerDemoActivity.java    License: Apache License 2.0 6 votes vote down vote up
public TasksManagerModel addTask(final String url, final String path) {
    if (TextUtils.isEmpty(url) || TextUtils.isEmpty(path)) {
        return null;
    }

    // have to use FileDownloadUtils.generateId to associate TasksManagerModel with FileDownloader
    final int id = FileDownloadUtils.generateId(url, path);

    TasksManagerModel model = new TasksManagerModel();
    model.setId(id);
    model.setName(DemoApplication.CONTEXT.getString(R.string.tasks_manager_demo_name, id));
    model.setUrl(url);
    model.setPath(path);

    final boolean succeed = db.insert(TABLE_NAME, null, model.toContentValues()) != -1;
    return succeed ? model : null;
}
 
Example 11
Source Project: FileDownloader   Source File: FileDownloader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Clear the data with the provided {@code id}.
 * Normally used to deleting the data in filedownloader database, when it is paused or in
 * downloading status. If you want to re-download it clearly.
 * <p/>
 * <strong>Note:</strong> YOU NO NEED to clear the data when it is already completed downloading
 * because the data would be deleted when it completed downloading automatically by
 * FileDownloader.
 * <p>
 * If there are tasks with the {@code id} in downloading, will be paused first;
 * If delete the data with the {@code id} in the filedownloader database successfully, will try
 * to delete its intermediate downloading file and downloaded file.
 *
 * @param id             the download {@code id}.
 * @param targetFilePath the target path.
 * @return {@code true} if the data with the {@code id} in filedownloader database was deleted,
 * and tasks with the {@code id} was paused; {@code false} otherwise.
 */
public boolean clear(final int id, final String targetFilePath) {
    pause(id);

    if (FileDownloadServiceProxy.getImpl().clearTaskData(id)) {
        // delete the task data in the filedownloader database successfully or no data with the
        // id in filedownloader database.
        final File intermediateFile = new File(FileDownloadUtils.getTempPath(targetFilePath));
        if (intermediateFile.exists()) {
            //noinspection ResultOfMethodCallIgnored
            intermediateFile.delete();
        }

        final File targetFile = new File(targetFilePath);
        if (targetFile.exists()) {
            //noinspection ResultOfMethodCallIgnored
            targetFile.delete();
        }

        return true;
    }

    return false;
}
 
Example 12
Source Project: FileDownloader   Source File: FileDownloader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param id   The downloadId.
 * @param path The target file path.
 * @return the downloading status.
 * @see FileDownloadStatus
 * @see #getStatus(String, String)
 * @see #getStatusIgnoreCompleted(int)
 */
public byte getStatus(final int id, final String path) {
    byte status;
    BaseDownloadTask.IRunningTask task = FileDownloadList.getImpl().get(id);
    if (task == null) {
        status = FileDownloadServiceProxy.getImpl().getStatus(id);
    } else {
        status = task.getOrigin().getStatus();
    }

    if (path != null && status == FileDownloadStatus.INVALID_STATUS) {
        if (FileDownloadUtils.isFilenameConverted(FileDownloadHelper.getAppContext())
                && new File(path).exists()) {
            status = FileDownloadStatus.completed;
        }
    }

    return status;
}
 
Example 13
Source Project: FileDownloader   Source File: SqliteDatabaseImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<ConnectionModel> findConnectionModel(int id) {
    final List<ConnectionModel> resultList = new ArrayList<>();

    Cursor c = null;
    try {
        c = db.rawQuery(FileDownloadUtils.formatString("SELECT * FROM %s WHERE %s = ?",
                CONNECTION_TABLE_NAME, ConnectionModel.ID), new String[]{Integer.toString(id)});

        while (c.moveToNext()) {
            final ConnectionModel model = new ConnectionModel();
            model.setId(id);
            model.setIndex(c.getInt(c.getColumnIndex(ConnectionModel.INDEX)));
            model.setStartOffset(c.getLong(c.getColumnIndex(ConnectionModel.START_OFFSET)));
            model.setCurrentOffset(c.getLong(c.getColumnIndex(ConnectionModel.CURRENT_OFFSET)));
            model.setEndOffset(c.getLong(c.getColumnIndex(ConnectionModel.END_OFFSET)));

            resultList.add(model);
        }
    } finally {
        if (c != null) c.close();
    }

    return resultList;
}
 
Example 14
Source Project: FileDownloader   Source File: DownloadLaunchRunnable.java    License: Apache License 2.0 6 votes vote down vote up
private void handlePreAllocate(long totalLength, String path)
        throws IOException, IllegalAccessException {

    FileDownloadOutputStream outputStream = null;
    try {

        if (totalLength != TOTAL_VALUE_IN_CHUNKED_RESOURCE) {
            outputStream = FileDownloadUtils.createOutputStream(model.getTempFilePath());
            final long breakpointBytes = new File(path).length();
            final long requiredSpaceBytes = totalLength - breakpointBytes;

            final long freeSpaceBytes = FileDownloadUtils.getFreeSpaceBytes(path);

            if (freeSpaceBytes < requiredSpaceBytes) {
                // throw a out of space exception.
                throw new FileDownloadOutOfSpaceException(freeSpaceBytes,
                        requiredSpaceBytes, breakpointBytes);
            } else if (!FileDownloadProperties.getImpl().fileNonPreAllocation) {
                // pre allocate.
                outputStream.setLength(totalLength);
            }
        }
    } finally {
        if (outputStream != null) outputStream.close();
    }
}
 
Example 15
Source Project: FileDownloader   Source File: DownloadLaunchRunnable.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean isRetry(Exception exception) {
    if (exception instanceof FileDownloadHttpException) {
        final FileDownloadHttpException httpException = (FileDownloadHttpException) exception;

        final int code = httpException.getCode();

        if (isSingleConnection && code == HTTP_REQUESTED_RANGE_NOT_SATISFIABLE) {
            if (!isTriedFixRangeNotSatisfiable) {
                FileDownloadUtils
                        .deleteTaskFiles(model.getTargetFilePath(), model.getTempFilePath());
                isTriedFixRangeNotSatisfiable = true;
                return true;
            }
        }
    }

    return validRetryTimes > 0 && !(exception instanceof FileDownloadGiveUpRetryException);
}
 
Example 16
Source Project: FileDownloader   Source File: DownloadLaunchRunnable.java    License: Apache License 2.0 6 votes vote down vote up
private void checkupBeforeConnect()
        throws FileDownloadGiveUpRetryException {

    // 1. check whether need access-network-state permission?
    if (isWifiRequired
            && !FileDownloadUtils.checkPermission(Manifest.permission.ACCESS_NETWORK_STATE)) {
        throw new FileDownloadGiveUpRetryException(
                FileDownloadUtils.formatString("Task[%d] can't start the download runnable,"
                                + " because this task require wifi, but user application "
                                + "nor current process has %s, so we can't check whether "
                                + "the network type connection.", model.getId(),
                        Manifest.permission.ACCESS_NETWORK_STATE));
    }

    // 2. check whether need wifi to download?
    if (isWifiRequired && FileDownloadUtils.isNetworkNotOnWifiType()) {
        throw new FileDownloadNetworkPolicyException();
    }
}
 
Example 17
Source Project: FileDownloader   Source File: DownloadStatusCallback.java    License: Apache License 2.0 6 votes vote down vote up
void onConnected(boolean isResume, long totalLength, String etag, String fileName) throws
        IllegalArgumentException {
    final String oldEtag = model.getETag();
    if (oldEtag != null && !oldEtag.equals(etag)) throw
            new IllegalArgumentException(FileDownloadUtils.formatString("callback "
                            + "onConnected must with precondition succeed, but the etag is "
                            + "changes(%s != %s)",
                    etag, oldEtag));

    // direct
    processParams.setResuming(isResume);

    model.setStatus(FileDownloadStatus.connected);
    model.setTotal(totalLength);
    model.setETag(etag);
    model.setFilename(fileName);

    database.updateConnected(model.getId(), totalLength, etag, fileName);
    onStatusChanged(FileDownloadStatus.connected);

    callbackMinIntervalBytes = calculateCallbackMinIntervalBytes(totalLength,
            callbackProgressMaxCount);
    needSetProcess.compareAndSet(false, true);
}
 
Example 18
Source Project: FileDownloader   Source File: ConnectionProfile.java    License: Apache License 2.0 6 votes vote down vote up
public void processProfile(FileDownloadConnection connection) throws ProtocolException {
    if (isForceNoRange) return;

    if (isTrialConnect && FileDownloadProperties.getImpl().trialConnectionHeadMethod) {
        connection.setRequestMethod("HEAD");
    }

    final String range;
    if (endOffset == RANGE_INFINITE) {
        range = FileDownloadUtils.formatString("bytes=%d-", currentOffset);
    } else {
        range = FileDownloadUtils
                .formatString("bytes=%d-%d", currentOffset, endOffset);
    }
    connection.addHeader("Range", range);
}
 
Example 19
Source Project: FileDownloader   Source File: FileDownloadService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    FileDownloadHelper.holdContext(this);

    try {
        FileDownloadUtils.setMinProgressStep(
                FileDownloadProperties.getImpl().downloadMinProgressStep);
        FileDownloadUtils.setMinProgressTime(
                FileDownloadProperties.getImpl().downloadMinProgressTime);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    final FileDownloadManager manager = new FileDownloadManager();

    if (FileDownloadProperties.getImpl().processNonSeparate) {
        handler = new FDServiceSharedHandler(new WeakReference<>(this), manager);
    } else {
        handler = new FDServiceSeparateHandler(new WeakReference<>(this), manager);
    }

    PauseAllMarker.clearMarker();
    pauseAllMarker = new PauseAllMarker((IFileDownloadIPCService) handler);
    pauseAllMarker.startPauseAllLooperCheck();
}
 
Example 20
@Override
public void bindStartByContext(Context context, Runnable connectedRunnable) {
    if (connectedRunnable != null) {
        if (!connectedRunnableList.contains(connectedRunnable)) {
            connectedRunnableList.add(connectedRunnable);
        }
    }
    Intent i = new Intent(context, SERVICE_CLASS);
    runServiceForeground = FileDownloadUtils.needMakeServiceForeground(context);
    i.putExtra(ExtraKeys.IS_FOREGROUND, runServiceForeground);
    if (runServiceForeground) {
        if (FileDownloadLog.NEED_LOG) FileDownloadLog.d(this, "start foreground service");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(i);
    } else  {
        context.startService(i);
    }
}
 
Example 21
Source Project: FileDownloader   Source File: DownloadTask.java    License: Apache License 2.0 6 votes vote down vote up
private int startTaskUnchecked() {
    if (isUsing()) {
        if (isRunning()) {
            throw new IllegalStateException(
                    FileDownloadUtils.formatString("This task is running %d, if you"
                            + " want to start the same task, please create a new one by"
                            + " FileDownloader.create", getId()));
        } else {
            throw new IllegalStateException("This task is dirty to restart, If you want to "
                    + "reuse this task, please invoke #reuse method manually and retry to "
                    + "restart again." + mHunter.toString());
        }
    }

    if (!isAttached()) {
        setAttachKeyDefault();
    }

    mHunter.intoLaunchPool();

    return getId();
}
 
Example 22
Source Project: YCAudioPlayer   Source File: TasksManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 创建一个下载文件的路径
 * @param url               下载url
 * @return                  路径
 */
public String createPath(final String url) {
    if (TextUtils.isEmpty(url)) {
        return null;
    }
    return FileDownloadUtils.getDefaultSaveFilePath(url);
}
 
Example 23
Source Project: YCAudioPlayer   Source File: TasksManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取下载文件的下载id
 * @param url                   下载链接
 * @return                      下载id
 */
public int getId(String url) {
    if (TextUtils.isEmpty(url)){
        return -1 ;
    }
    return FileDownloadUtils.generateId(url, createPath(url));
}
 
Example 24
Source Project: YCAudioPlayer   Source File: TasksManagerDBController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 添加到数据库
 * @param url                   下载链接
 * @param path                  下载路径
 * @return                      实体类model
 */
TasksManagerModel addTask(final String url, final String path) {
    if (TextUtils.isEmpty(url) || TextUtils.isEmpty(path)) {
        return null;
    }
    // 必须使用文件下载器,将TasksManagerModel与文件下载器关联
    final int id = FileDownloadUtils.generateId(url, path);
    TasksManagerModel model = new TasksManagerModel();
    model.setId(id);
    model.setName(url.substring(url.lastIndexOf("/")));
    model.setUrl(url);
    model.setPath(path);
    final boolean succeed = db.insert(TABLE_NAME, null, model.toContentValues()) != -1;
    return succeed ? model : null;
}
 
Example 25
Source Project: okdownload   Source File: FileDownloadMonitor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void taskStart(DownloadTask task) {
    final DownloadTaskAdapter downloadTaskAdapter =
            FileDownloadUtils.findDownloadTaskAdapter(task);
    if (downloadTaskAdapter != null) {
        onTaskBegin(downloadTaskAdapter);
    }
}
 
Example 26
Source Project: okdownload   Source File: FileDownloadMonitor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void taskDownloadFromBeginning(
        @NonNull DownloadTask task, @NonNull BreakpointInfo info,
        @Nullable ResumeFailedCause cause) {
    final DownloadTaskAdapter downloadTaskAdapter =
            FileDownloadUtils.findDownloadTaskAdapter(task);
    if (downloadTaskAdapter != null) {
        onRequestStart(downloadTaskAdapter);
        onTaskStarted(downloadTaskAdapter);
    }
}
 
Example 27
Source Project: okdownload   Source File: FileDownloadMonitor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void taskEnd(DownloadTask task, EndCause cause, @Nullable Exception realCause) {
    final DownloadTaskAdapter downloadTaskAdapter =
            FileDownloadUtils.findDownloadTaskAdapter(task);
    if (downloadTaskAdapter != null) {
        onTaskOver(downloadTaskAdapter);
    }
}
 
Example 28
Source Project: okdownload   Source File: CompatListenerAssist.java    License: Apache License 2.0 5 votes vote down vote up
public void taskStart(@NonNull DownloadTask task) {
    final DownloadTaskAdapter downloadTaskAdapter =
            FileDownloadUtils.findDownloadTaskAdapter(task);
    if (downloadTaskAdapter == null) return;
    final long soFarBytes = downloadTaskAdapter.getSoFarBytesInLong();
    final long totalBytes = downloadTaskAdapter.getTotalBytesInLong();
    callback.pending(downloadTaskAdapter, soFarBytes, totalBytes);
    callback.started(downloadTaskAdapter);
}
 
Example 29
Source Project: okdownload   Source File: CompatListenerAssist.java    License: Apache License 2.0 5 votes vote down vote up
public void connectStart(DownloadTask task) {
    if (taskConnected.compareAndSet(false, true)) {
        final DownloadTaskAdapter downloadTaskAdapter =
                FileDownloadUtils.findDownloadTaskAdapter(task);
        if (downloadTaskAdapter == null) return;
        final long soFarBytes = downloadTaskAdapter.getSoFarBytesInLong();
        final long totalBytes = downloadTaskAdapter.getTotalBytesInLong();
        downloadTaskAdapter.getProgressAssist().initSofarBytes(soFarBytes);
        downloadTaskAdapter.getProgressAssist().calculateCallbackMinIntervalBytes(totalBytes);
        callback.connected(downloadTaskAdapter, etag, resumable, soFarBytes, totalBytes);
    }
}
 
Example 30
Source Project: okdownload   Source File: CompatListenerAssist.java    License: Apache License 2.0 5 votes vote down vote up
public void fetchProgress(@NonNull DownloadTask task, long increaseBytes) {
    final DownloadTaskAdapter downloadTaskAdapter =
            FileDownloadUtils.findDownloadTaskAdapter(task);
    if (downloadTaskAdapter == null) return;
    downloadTaskAdapter.getProgressAssist()
            .onProgress(downloadTaskAdapter, increaseBytes, callback);
}