Java Code Examples for com.liulishuo.filedownloader.model.FileDownloadStatus#warn()
The following examples show how to use
com.liulishuo.filedownloader.model.FileDownloadStatus#warn() .
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: DownloadHelper.java From Mysplash with GNU Lesser General Public License v3.0 | 5 votes |
private int getDownloadResult(DownloadMissionEntity entity) { switch (FileDownloader.getImpl().getStatus((int) entity.missionId, entity.getFilePath())) { case FileDownloadStatus.completed: return RESULT_SUCCEED; case FileDownloadStatus.error: case FileDownloadStatus.warn: case FileDownloadStatus.paused: return RESULT_FAILED; default: return RESULT_DOWNLOADING; } }
Example 2
Source File: DownloadTaskHunter.java From FileDownloader with Apache License 2.0 | 5 votes |
@Override public boolean updateSameFilePathTaskRunning(MessageSnapshot snapshot) { if (!mTask.getRunningTask().getOrigin().isPathAsDirectory()) { return false; } if (snapshot.getStatus() != FileDownloadStatus.warn || getStatus() != FileDownloadStatus.connected) { return false; } update(snapshot); return true; }
Example 3
Source File: DownloadVideoAdapter.java From v9porn with MIT License | 4 votes |
@Override protected void convert(BaseViewHolder helper, V9PornItem item) { helper.setText(R.id.tv_91porn_item_title, item.getTitleWithDuration()); ImageView simpleDraweeView = helper.getView(R.id.iv_91porn_item_img); Uri uri = Uri.parse(item.getImgUrl()); GlideApp.with(helper.itemView).load(uri).placeholder(R.drawable.placeholder).transition(new DrawableTransitionOptions().crossFade(300)).into(simpleDraweeView); helper.setProgress(R.id.progressBar_download, item.getProgress()); helper.setText(R.id.tv_download_progress, String.valueOf(item.getProgress()) + "%"); helper.setText(R.id.tv_download_filesize, Formatter.formatFileSize(helper.itemView.getContext(), item.getSoFarBytes()).replace("MB", "") + "/ " + Formatter.formatFileSize(helper.itemView.getContext(), item.getTotalFarBytes())); if (item.getStatus() == FileDownloadStatus.completed) { helper.setText(R.id.tv_download_speed, "已完成"); helper.setVisible(R.id.iv_download_control, false); } else { //未下载完成,显示控制 helper.setVisible(R.id.iv_download_control, true); if (FileDownloader.getImpl().isServiceConnected()) { helper.setImageResource(R.id.iv_download_control, R.drawable.pause_download); if (item.getStatus() == FileDownloadStatus.progress) { helper.setText(R.id.tv_download_speed, item.getSpeed() + " KB/s"); } else if (item.getStatus() == FileDownloadStatus.paused) { helper.setText(R.id.tv_download_speed, "暂停中"); helper.setImageResource(R.id.iv_download_control, R.drawable.start_download); } else if (item.getStatus() == FileDownloadStatus.pending) { helper.setText(R.id.tv_download_speed, "准备中"); } else if (item.getStatus() == FileDownloadStatus.started) { helper.setText(R.id.tv_download_speed, "开始下载"); } else if (item.getStatus() == FileDownloadStatus.connected) { helper.setText(R.id.tv_download_speed, "连接中"); } else if (item.getStatus() == FileDownloadStatus.error) { helper.setText(R.id.tv_download_speed, "下载错误"); helper.setImageResource(R.id.iv_download_control, R.drawable.start_download); } else if (item.getStatus() == FileDownloadStatus.retry) { helper.setText(R.id.tv_download_speed, "重试中"); } else if (item.getStatus() == FileDownloadStatus.warn) { helper.setText(R.id.tv_download_speed, "警告"); helper.setImageResource(R.id.iv_download_control, R.drawable.start_download); } } else { helper.setText(R.id.tv_download_speed, "暂停中"); helper.setImageResource(R.id.iv_download_control, R.drawable.start_download); } } helper.addOnClickListener(R.id.iv_download_control); helper.addOnClickListener(R.id.right_menu_delete); }
Example 4
Source File: DownloadVideoAdapter.java From v9porn with MIT License | 4 votes |
@Override protected void convert(BaseViewHolder helper, V9PornItem item) { helper.setText(R.id.tv_91porn_item_title, item.getTitleWithDuration()); ImageView simpleDraweeView = helper.getView(R.id.iv_91porn_item_img); Uri uri = Uri.parse(item.getImgUrl()); GlideApp.with(helper.itemView).load(uri).placeholder(R.drawable.placeholder).transition(new DrawableTransitionOptions().crossFade(300)).into(simpleDraweeView); helper.setProgress(R.id.progressBar_download, item.getProgress()); helper.setText(R.id.tv_download_progress, String.valueOf(item.getProgress()) + "%"); helper.setText(R.id.tv_download_filesize, Formatter.formatFileSize(helper.itemView.getContext(), item.getSoFarBytes()).replace("MB", "") + "/ " + Formatter.formatFileSize(helper.itemView.getContext(), item.getTotalFarBytes())); if (item.getStatus() == FileDownloadStatus.completed) { helper.setText(R.id.tv_download_speed, "已完成"); helper.setVisible(R.id.iv_download_control, false); } else { //未下载完成,显示控制 helper.setVisible(R.id.iv_download_control, true); if (FileDownloader.getImpl().isServiceConnected()) { helper.setImageResource(R.id.iv_download_control, R.drawable.pause_download); if (item.getStatus() == FileDownloadStatus.progress) { helper.setText(R.id.tv_download_speed, item.getSpeed() + " KB/s"); } else if (item.getStatus() == FileDownloadStatus.paused) { helper.setText(R.id.tv_download_speed, "暂停中"); helper.setImageResource(R.id.iv_download_control, R.drawable.start_download); } else if (item.getStatus() == FileDownloadStatus.pending) { helper.setText(R.id.tv_download_speed, "准备中"); } else if (item.getStatus() == FileDownloadStatus.started) { helper.setText(R.id.tv_download_speed, "开始下载"); } else if (item.getStatus() == FileDownloadStatus.connected) { helper.setText(R.id.tv_download_speed, "连接中"); } else if (item.getStatus() == FileDownloadStatus.error) { helper.setText(R.id.tv_download_speed, "下载错误"); helper.setImageResource(R.id.iv_download_control, R.drawable.start_download); } else if (item.getStatus() == FileDownloadStatus.retry) { helper.setText(R.id.tv_download_speed, "重试中"); } else if (item.getStatus() == FileDownloadStatus.warn) { helper.setText(R.id.tv_download_speed, "警告"); helper.setImageResource(R.id.iv_download_control, R.drawable.start_download); } } else { helper.setText(R.id.tv_download_speed, "暂停中"); helper.setImageResource(R.id.iv_download_control, R.drawable.start_download); } } helper.addOnClickListener(R.id.iv_download_control); helper.addOnClickListener(R.id.right_menu_delete); }
Example 5
Source File: NotificationSampleActivity.java From FileDownloader with Apache License 2.0 | 4 votes |
@Override public void show(boolean statusChanged, int status, boolean isShowProgress) { String desc = ""; switch (status) { case FileDownloadStatus.pending: desc += " pending"; builder.setProgress(getTotal(), getSofar(), true); break; case FileDownloadStatus.started: desc += " started"; builder.setProgress(getTotal(), getSofar(), true); break; case FileDownloadStatus.progress: desc += " progress"; builder.setProgress(getTotal(), getSofar(), getTotal() <= 0); break; case FileDownloadStatus.retry: desc += " retry"; builder.setProgress(getTotal(), getSofar(), true); break; case FileDownloadStatus.error: desc += " error"; builder.setProgress(getTotal(), getSofar(), false); break; case FileDownloadStatus.paused: desc += " paused"; builder.setProgress(getTotal(), getSofar(), false); break; case FileDownloadStatus.completed: desc += " completed"; builder.setProgress(getTotal(), getSofar(), false); break; case FileDownloadStatus.warn: desc += " warn"; builder.setProgress(0, 0, true); break; } builder.setContentTitle(getTitle()).setContentText(desc); getManager().notify(getId(), builder.build()); }
Example 6
Source File: MessageSnapshot.java From FileDownloader with Apache License 2.0 | 4 votes |
@Override public MessageSnapshot createFromParcel(Parcel source) { boolean largeFile = source.readByte() == 1; byte status = source.readByte(); final MessageSnapshot snapshot; switch (status) { case FileDownloadStatus.pending: if (largeFile) { snapshot = new LargeMessageSnapshot.PendingMessageSnapshot(source); } else { snapshot = new SmallMessageSnapshot.PendingMessageSnapshot(source); } break; case FileDownloadStatus.started: snapshot = new StartedMessageSnapshot(source); break; case FileDownloadStatus.connected: if (largeFile) { snapshot = new LargeMessageSnapshot.ConnectedMessageSnapshot(source); } else { snapshot = new SmallMessageSnapshot.ConnectedMessageSnapshot(source); } break; case FileDownloadStatus.progress: if (largeFile) { snapshot = new LargeMessageSnapshot.ProgressMessageSnapshot(source); } else { snapshot = new SmallMessageSnapshot.ProgressMessageSnapshot(source); } break; case FileDownloadStatus.retry: if (largeFile) { snapshot = new LargeMessageSnapshot.RetryMessageSnapshot(source); } else { snapshot = new SmallMessageSnapshot.RetryMessageSnapshot(source); } break; case FileDownloadStatus.error: if (largeFile) { snapshot = new LargeMessageSnapshot.ErrorMessageSnapshot(source); } else { snapshot = new SmallMessageSnapshot.ErrorMessageSnapshot(source); } break; case FileDownloadStatus.completed: if (largeFile) { snapshot = new LargeMessageSnapshot.CompletedSnapshot(source); } else { snapshot = new SmallMessageSnapshot.CompletedSnapshot(source); } break; case FileDownloadStatus.warn: if (largeFile) { snapshot = new LargeMessageSnapshot.WarnMessageSnapshot(source); } else { snapshot = new SmallMessageSnapshot.WarnMessageSnapshot(source); } break; default: snapshot = null; } if (snapshot != null) { snapshot.isLargeFile = largeFile; } else { throw new IllegalStateException("Can't restore the snapshot because unknown " + "status: " + status); } return snapshot; }
Example 7
Source File: SmallMessageSnapshot.java From FileDownloader with Apache License 2.0 | 4 votes |
@Override public byte getStatus() { return FileDownloadStatus.warn; }
Example 8
Source File: LargeMessageSnapshot.java From FileDownloader with Apache License 2.0 | 4 votes |
@Override public byte getStatus() { return FileDownloadStatus.warn; }
Example 9
Source File: FileDownloadList.java From FileDownloader with Apache License 2.0 | 4 votes |
/** * @param willRemoveDownload will be remove */ public boolean remove(final BaseDownloadTask.IRunningTask willRemoveDownload, MessageSnapshot snapshot) { final byte removeByStatus = snapshot.getStatus(); boolean succeed; synchronized (mList) { succeed = mList.remove(willRemoveDownload); if (succeed && mList.size() == 0) { if (FileDownloadServiceProxy.getImpl().isRunServiceForeground()) { FileDownloader.getImpl().stopForeground(true); } } } if (FileDownloadLog.NEED_LOG) { if (mList.size() == 0) { FileDownloadLog.v(this, "remove %s left %d %d", willRemoveDownload, removeByStatus, mList.size()); } } if (succeed) { final IFileDownloadMessenger messenger = willRemoveDownload.getMessageHandler(). getMessenger(); // Notify 2 Listener switch (removeByStatus) { case FileDownloadStatus.warn: messenger.notifyWarn(snapshot); break; case FileDownloadStatus.error: messenger.notifyError(snapshot); break; case FileDownloadStatus.paused: messenger.notifyPaused(snapshot); break; case FileDownloadStatus.completed: messenger .notifyBlockComplete(MessageSnapshotTaker.takeBlockCompleted(snapshot)); break; default: // ignored } } else { FileDownloadLog.e(this, "remove error, not exist: %s %d", willRemoveDownload, removeByStatus); } return succeed; }