Java Code Examples for com.lzy.okgo.model.Progress#WAITING
The following examples show how to use
com.lzy.okgo.model.Progress#WAITING .
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: UploadAdapter.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
public void refresh(Progress progress) { String currentSize = Formatter.formatFileSize(context, progress.currentSize); String totalSize = Formatter.formatFileSize(context, progress.totalSize); downloadSize.setText(currentSize + "/" + totalSize); priority.setText(String.format("优先级:%s", progress.priority)); switch (progress.status) { case Progress.NONE: netSpeed.setText("停止"); upload.setText("上传"); break; case Progress.PAUSE: netSpeed.setText("暂停中"); upload.setText("继续"); break; case Progress.ERROR: netSpeed.setText("上传出错"); upload.setText("出错"); break; case Progress.WAITING: netSpeed.setText("等待中"); upload.setText("等待"); break; case Progress.FINISH: upload.setText("完成"); netSpeed.setText("上传成功"); break; case Progress.LOADING: String speed = Formatter.formatFileSize(context, progress.speed); netSpeed.setText(String.format("%s/s", speed)); upload.setText("停止"); break; } tvProgress.setText(numberFormat.format(progress.fraction)); pbProgress.setMax(10000); pbProgress.setProgress((int) (progress.fraction * 10000)); }
Example 2
Source File: DownloadAdapter.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
public void refresh(Progress progress) { String currentSize = Formatter.formatFileSize(context, progress.currentSize); String totalSize = Formatter.formatFileSize(context, progress.totalSize); downloadSize.setText(currentSize + "/" + totalSize); priority.setText(String.format("优先级:%s", progress.priority)); switch (progress.status) { case Progress.NONE: netSpeed.setText("停止"); download.setText("下载"); break; case Progress.PAUSE: netSpeed.setText("暂停中"); download.setText("继续"); break; case Progress.ERROR: netSpeed.setText("下载出错"); download.setText("出错"); break; case Progress.WAITING: netSpeed.setText("等待中"); download.setText("等待"); break; case Progress.FINISH: netSpeed.setText("下载完成"); download.setText("完成"); break; case Progress.LOADING: String speed = Formatter.formatFileSize(context, progress.speed); netSpeed.setText(String.format("%s/s", speed)); download.setText("暂停"); break; } tvProgress.setText(numberFormat.format(progress.fraction)); pbProgress.setMax(10000); pbProgress.setProgress((int) (progress.fraction * 10000)); }
Example 3
Source File: DesActivity.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
private void refreshUi(Progress progress) { String currentSize = Formatter.formatFileSize(this, progress.currentSize); String totalSize = Formatter.formatFileSize(this, progress.totalSize); downloadSize.setText(currentSize + "/" + totalSize); String speed = Formatter.formatFileSize(this, progress.speed); netSpeed.setText(String.format("%s/s", speed)); tvProgress.setText(numberFormat.format(progress.fraction)); pbProgress.setMax(10000); pbProgress.setProgress((int) (progress.fraction * 10000)); switch (progress.status) { case Progress.NONE: download.setText("下载"); break; case Progress.LOADING: download.setText("暂停"); break; case Progress.PAUSE: download.setText("继续"); break; case Progress.WAITING: download.setText("等待"); break; case Progress.ERROR: download.setText("出错"); break; case Progress.FINISH: if (ApkUtils.isAvailable(this, new File(progress.filePath))) { download.setText("卸载"); } else { download.setText("安装"); } break; } }
Example 4
Source File: UploadTask.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
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 5
Source File: UploadTask.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
/** 暂停的方法 */ 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 6
Source File: UploadTask.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
private void postWaiting(final Progress progress) { progress.speed = 0; progress.status = Progress.WAITING; updateDatabase(progress); HttpUtils.runOnUiThread(new Runnable() { @Override public void run() { for (UploadListener<T> listener : listeners.values()) { listener.onProgress(progress); } } }); }
Example 7
Source File: DownloadTask.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
/** 暂停的方法 */ 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 8
Source File: DownloadTask.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
private void postWaiting(final Progress progress) { progress.speed = 0; progress.status = Progress.WAITING; updateDatabase(progress); HttpUtils.runOnUiThread(new Runnable() { @Override public void run() { for (DownloadListener listener : listeners.values()) { listener.onProgress(progress); } } }); }
Example 9
Source File: OkDownload.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
private OkDownload() { folder = Environment.getExternalStorageDirectory() + File.separator + "download" + File.separator; IOUtils.createFolder(folder); threadPool = new DownloadThreadPool(); taskMap = new ConcurrentHashMap<>(); //校验数据的有效性,防止下载过程中退出,第二次进入的时候,由于状态没有更新导致的状态错误 List<Progress> taskList = DownloadManager.getInstance().getDownloading(); for (Progress info : taskList) { if (info.status == Progress.WAITING || info.status == Progress.LOADING || info.status == Progress.PAUSE) { info.status = Progress.NONE; } } DownloadManager.getInstance().replace(taskList); }
Example 10
Source File: OkUpload.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
private OkUpload() { threadPool = new UploadThreadPool(); taskMap = new LinkedHashMap<>(); //校验数据的有效性,防止下载过程中退出,第二次进入的时候,由于状态没有更新导致的状态错误 List<Progress> taskList = UploadManager.getInstance().getUploading(); for (Progress info : taskList) { if (info.status == Progress.WAITING || info.status == Progress.LOADING || info.status == Progress.PAUSE) { info.status = Progress.NONE; } } UploadManager.getInstance().replace(taskList); }