Java Code Examples for com.liulishuo.filedownloader.model.FileDownloadStatus#isOver()

The following examples show how to use com.liulishuo.filedownloader.model.FileDownloadStatus#isOver() . 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: DownloadTaskHunter.java    From FileDownloader with Apache License 2.0 6 votes vote down vote up
@Override
public void reset() {
    mThrowable = null;

    mEtag = null;
    mIsResuming = false;
    mRetryingTimes = 0;
    mIsReusedOldFile = false;
    mIsLargeFile = false;

    mSoFarBytes = 0;
    mTotalBytes = 0;

    mSpeedMonitor.reset();

    if (FileDownloadStatus.isOver(mStatus)) {
        mMessenger.discard();
        mMessenger = new FileDownloadMessenger(mTask.getRunningTask(), this);
    } else {
        mMessenger.reAppointment(mTask.getRunningTask(), this);
    }

    mStatus = FileDownloadStatus.INVALID_STATUS;
}
 
Example 2
Source File: FileDownloadMessenger.java    From FileDownloader with Apache License 2.0 5 votes vote down vote up
private void inspectAndHandleOverStatus(int status) {
    // If this task is in the over state, try to retire this messenger.
    if (FileDownloadStatus.isOver(status)) {
        if (!parcelQueue.isEmpty()) {
            final MessageSnapshot queueTopTask = parcelQueue.peek();
            FileDownloadLog.w(this,
                    "the messenger[%s](with id[%d]) has already "
                            + "accomplished all his job, but there still are some messages in"
                            + " parcel queue[%d] queue-top-status[%d]",
                    this, queueTopTask.getId(), parcelQueue.size(), queueTopTask.getStatus());
        }
        mTask = null;
    }
}
 
Example 3
Source File: StatusAssist.java    From okdownload with Apache License 2.0 4 votes vote down vote up
public synchronized boolean isOver() {
    return FileDownloadStatus.isOver(getStatus());
}
 
Example 4
Source File: DownloadTaskHunter.java    From FileDownloader with Apache License 2.0 4 votes vote down vote up
@Override
public boolean pause() {
    if (FileDownloadStatus.isOver(getStatus())) {
        if (FileDownloadLog.NEED_LOG) {
            /**
             * The over-mStatus call-backed and set the over-mStatus to this task between here
             * area and remove from the {@link FileDownloadList}.
             *
             * High concurrent cause.
             */
            FileDownloadLog.d(this, "High concurrent cause, Already is over, can't pause "
                    + "again, %d %d", getStatus(), mTask.getRunningTask().getOrigin().getId());
        }
        return false;
    }
    this.mStatus = FileDownloadStatus.paused;

    final BaseDownloadTask.IRunningTask runningTask = mTask.getRunningTask();
    final BaseDownloadTask origin = runningTask.getOrigin();

    FileDownloadTaskLauncher.getImpl().expire(this);
    if (FileDownloadLog.NEED_LOG) {
        FileDownloadLog.v(this, "the task[%d] has been expired from the launch pool.", getId());
    }

    if (!FileDownloader.getImpl().isServiceConnected()) {
        if (FileDownloadLog.NEED_LOG) {
            FileDownloadLog.d(this, "request pause the task[%d] to the download service,"
                    + " but the download service isn't connected yet.", origin.getId());
        }
    } else {
        FileDownloadServiceProxy.getImpl().pause(origin.getId());
    }

    // For make sure already added event mListener for receive paused event
    FileDownloadList.getImpl().add(runningTask);
    FileDownloadList.getImpl().remove(runningTask, MessageSnapshotTaker.catchPause(origin));

    FileDownloader.getImpl().getLostConnectedHandler().taskWorkFine(runningTask);

    return true;
}
 
Example 5
Source File: DownloadTask.java    From FileDownloader with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isOver() {
    return FileDownloadStatus.isOver(getStatus());
}