Java Code Examples for com.liulishuo.filedownloader.BaseDownloadTask#getSmallFileSoFarBytes()

The following examples show how to use com.liulishuo.filedownloader.BaseDownloadTask#getSmallFileSoFarBytes() . 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 File: DownloadManager.java    From v9porn with MIT License 5 votes vote down vote up
/**
 * 实时保存下载信息
 *
 * @param task 任务信息
 */
private void saveDownloadInfo(BaseDownloadTask task) {
    V9PornItem v9PornItem = dataManager.findV9PornItemByDownloadId(task.getId());
    if (v9PornItem == null) {
        //不存在的任务清除掉
        FileDownloader.getImpl().clear(task.getId(), task.getPath());
        if (!BuildConfig.DEBUG) {
          //  Bugsnag.notify(new Throwable(TAG + "::save download info failure:" + task.getUrl()), Severity.WARNING);
        }
        return;
    }
    int soFarBytes = task.getSmallFileSoFarBytes();
    int totalBytes = task.getSmallFileTotalBytes();
    if (soFarBytes > 0) {
        v9PornItem.setSoFarBytes(soFarBytes);
    }

    if (totalBytes > 0) {
        v9PornItem.setTotalFarBytes(totalBytes);
    }
    if (totalBytes > 0) {
        int p = (int) (((float) soFarBytes / totalBytes) * 100);
        v9PornItem.setProgress(p);
    }
    if (task.getStatus() == FileDownloadStatus.completed) {
        v9PornItem.setFinishedDownloadDate(new Date());
    }
    v9PornItem.setSpeed(task.getSpeed());
    v9PornItem.setStatus(task.getStatus());
    dataManager.updateV9PornItem(v9PornItem);
    if (task.getStatus() == FileDownloadStatus.completed) {
        complete(task);
    } else {
        update(task);
    }
}
 
Example 2
Source File: DownloadManager.java    From v9porn with MIT License 5 votes vote down vote up
/**
 * 实时保存下载信息
 *
 * @param task 任务信息
 */
private void saveDownloadInfo(BaseDownloadTask task) {
    V9PornItem v9PornItem = dataManager.findV9PornItemByDownloadId(task.getId());
    if (v9PornItem == null) {
        //不存在的任务清除掉
        FileDownloader.getImpl().clear(task.getId(), task.getPath());
        if (!BuildConfig.DEBUG) {
          //  Bugsnag.notify(new Throwable(TAG + "::save download info failure:" + task.getUrl()), Severity.WARNING);
        }
        return;
    }
    int soFarBytes = task.getSmallFileSoFarBytes();
    int totalBytes = task.getSmallFileTotalBytes();
    if (soFarBytes > 0) {
        v9PornItem.setSoFarBytes(soFarBytes);
    }

    if (totalBytes > 0) {
        v9PornItem.setTotalFarBytes(totalBytes);
    }
    if (totalBytes > 0) {
        int p = (int) (((float) soFarBytes / totalBytes) * 100);
        v9PornItem.setProgress(p);
    }
    if (task.getStatus() == FileDownloadStatus.completed) {
        v9PornItem.setFinishedDownloadDate(new Date());
    }
    v9PornItem.setSpeed(task.getSpeed());
    v9PornItem.setStatus(task.getStatus());
    dataManager.updateV9PornItem(v9PornItem);
    if (task.getStatus() == FileDownloadStatus.completed) {
        complete(task);
    } else {
        update(task);
    }
}
 
Example 3
Source File: MessageSnapshotTaker.java    From FileDownloader with Apache License 2.0 5 votes vote down vote up
public static MessageSnapshot catchPause(BaseDownloadTask task) {
    if (task.isLargeFile()) {
        return new LargeMessageSnapshot.PausedSnapshot(task.getId(),
                task.getLargeFileSoFarBytes(), task.getLargeFileTotalBytes());
    } else {
        return new SmallMessageSnapshot.PausedSnapshot(task.getId(),
                task.getSmallFileSoFarBytes(), task.getSmallFileTotalBytes());
    }
}