Java Code Examples for com.lzy.okgo.utils.OkLogger#w()

The following examples show how to use com.lzy.okgo.utils.OkLogger#w() . 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: DownloadTask.java    From okhttp-OkGo with Apache License 2.0 6 votes vote down vote up
public void start() {
    if (OkDownload.getInstance().getTask(progress.tag) == null || DownloadManager.getInstance().get(progress.tag) == null) {
        throw new IllegalStateException("you must call DownloadTask#save() before DownloadTask#start()!");
    }
    if (progress.status == Progress.NONE || progress.status == Progress.PAUSE || progress.status == Progress.ERROR) {
        postOnStart(progress);
        postWaiting(progress);
        priorityRunnable = new PriorityRunnable(progress.priority, this);
        executor.execute(priorityRunnable);
    } else if (progress.status == Progress.FINISH) {
        if (progress.filePath == null) {
            postOnError(progress, new StorageException("the file of the task with tag:" + progress.tag + " may be invalid or damaged, please call the method restart() to download again!"));
        } else {
            File file = new File(progress.filePath);
            if (file.exists() && file.length() == progress.totalSize) {
                postOnFinish(progress, new File(progress.filePath));
            } else {
                postOnError(progress, new StorageException("the file " + progress.filePath + " may be invalid or damaged, please call the method restart() to download again!"));
            }
        }
    } else {
        OkLogger.w("the task with tag " + progress.tag + " is already in the download queue, current task status is " + progress.status);
    }
}
 
Example 2
Source File: UploadTask.java    From okhttp-OkGo with Apache License 2.0 5 votes vote down vote up
public UploadTask<T> start() {
    if (OkUpload.getInstance().getTask(progress.tag) == null || UploadManager.getInstance().get(progress.tag) == null) {
        throw new IllegalStateException("you must call UploadTask#save() before UploadTask#start()!");
    }
    if (progress.status != Progress.WAITING && progress.status != Progress.LOADING) {
        postOnStart(progress);
        postWaiting(progress);
        priorityRunnable = new PriorityRunnable(progress.priority, this);
        executor.execute(priorityRunnable);
    } else {
        OkLogger.w("the task with tag " + progress.tag + " is already in the upload queue, current task status is " + progress.status);
    }
    return this;
}
 
Example 3
Source File: UploadTask.java    From okhttp-OkGo with Apache License 2.0 5 votes vote down vote up
/** 暂停的方法 */
public void pause() {
    executor.remove(priorityRunnable);
    if (progress.status == Progress.WAITING) {
        postPause(progress);
    } else if (progress.status == Progress.LOADING) {
        progress.speed = 0;
        progress.status = Progress.PAUSE;
    } else {
        OkLogger.w("only the task with status WAITING(1) or LOADING(2) can pause, current status is " + progress.status);
    }
}
 
Example 4
Source File: DownloadTask.java    From okhttp-OkGo with Apache License 2.0 5 votes vote down vote up
/** 暂停的方法 */
public void pause() {
    executor.remove(priorityRunnable);
    if (progress.status == Progress.WAITING) {
        postPause(progress);
    } else if (progress.status == Progress.LOADING) {
        progress.speed = 0;
        progress.status = Progress.PAUSE;
    } else {
        OkLogger.w("only the task with status WAITING(1) or LOADING(2) can pause, current status is " + progress.status);
    }
}
 
Example 5
Source File: OkDownload.java    From okhttp-OkGo with Apache License 2.0 5 votes vote down vote up
/** 开始所有任务 */
public void startAll() {
    for (Map.Entry<String, DownloadTask> entry : taskMap.entrySet()) {
        DownloadTask task = entry.getValue();
        if (task == null) {
            OkLogger.w("can't find task with tag = " + entry.getKey());
            continue;
        }
        task.start();
    }
}
 
Example 6
Source File: OkUpload.java    From okhttp-OkGo with Apache License 2.0 5 votes vote down vote up
/** 开始所有任务 */
public void startAll() {
    for (Map.Entry<String, UploadTask<?>> entry : taskMap.entrySet()) {
        UploadTask<?> task = entry.getValue();
        if (task == null) {
            OkLogger.w("can't find task with tag = " + entry.getKey());
            continue;
        }
        task.start();
    }
}