Java Code Examples for com.liulishuo.filedownloader.model.FileDownloadStatus#started()
The following examples show how to use
com.liulishuo.filedownloader.model.FileDownloadStatus#started() .
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: TasksManagerDemoActivity.java From FileDownloader with Apache License 2.0 | 5 votes |
public void updateDownloading(final int status, final long sofar, final long total) { final float percent = sofar / (float) total; taskPb.setMax(100); taskPb.setProgress((int) (percent * 100)); switch (status) { case FileDownloadStatus.pending: taskStatusTv.setText(R.string.tasks_manager_demo_status_pending); break; case FileDownloadStatus.started: taskStatusTv.setText(R.string.tasks_manager_demo_status_started); break; case FileDownloadStatus.connected: taskStatusTv.setText(R.string.tasks_manager_demo_status_connected); break; case FileDownloadStatus.progress: taskStatusTv.setText(R.string.tasks_manager_demo_status_progress); break; default: taskStatusTv.setText(DemoApplication.CONTEXT.getString( R.string.tasks_manager_demo_status_downloading, status)); break; } taskActionBtn.setText(R.string.pause); }
Example 2
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 3
Source File: CacheDownloadingAdapter.java From YCAudioPlayer with Apache License 2.0 | 4 votes |
@Override public void updateDownloading(int status, long sofar, long total) { AppLogUtils.e("ViewHolder----"+"updateDownloading--------"); final float percent = sofar / (float) total; pb.setProgress((int) (percent * 100)); switch (status) { //排队中 case FileDownloadStatus.pending: ivDownload.setBackgroundResource(R.drawable.ic_note_btn_play_white); ivDownload.setTag(R.drawable.ic_note_btn_play_white); AppLogUtils.e("ViewHolder----"+"排队中--------"); tvState.setText("排队中"); break; //开始下载 case FileDownloadStatus.started: ivDownload.setBackgroundResource(R.drawable.ic_note_btn_play_white); ivDownload.setTag(R.drawable.ic_note_btn_play_white); AppLogUtils.e("ViewHolder----"+"开始下载--------"); tvState.setText("开始下载"); break; //链接中 case FileDownloadStatus.connected: ivDownload.setBackgroundResource(R.drawable.ic_note_btn_play_white); ivDownload.setTag(R.drawable.ic_note_btn_play_white); AppLogUtils.e("ViewHolder----"+"链接中--------"); tvState.setText("链接中"); break; //下载中 case FileDownloadStatus.progress: ivDownload.setBackgroundResource(R.drawable.ic_note_btn_pause_white); ivDownload.setTag(R.drawable.ic_note_btn_pause_white); AppLogUtils.e("ViewHolder----"+"下载中--------"); tvState.setText("下载中"); break; //默认 default: ivDownload.setBackgroundResource(R.drawable.ic_note_btn_pause_white); ivDownload.setTag(R.drawable.ic_note_btn_pause_white); AppLogUtils.e("ViewHolder----"+"默认--------"); tvState.setText("默认"); break; } }
Example 4
Source File: DialogListAdapter.java From YCAudioPlayer with Apache License 2.0 | 4 votes |
@SuppressLint("SetTextI18n") @Override public void onBindViewHolder(ViewHolder holder, @SuppressLint("RecyclerView") final int position) { DialogListBean model = mList.get(position); final String path = TasksManager.getImpl().createPath(model.getVideo()); int id = TasksManager.getImpl().getId(model.getVideo()); holder.update(id, position); holder.llDownload.setTag(holder); TasksManager.getImpl().updateViewHolder(holder.id, holder); AppLogUtils.e("onBindHolder----"+path+ "、、、、、"+id); holder.tvTitle.setText(mList.get(position).getTitle()); holder.tvTime.setText("时长98:00:12"); setCircleProgressbar(); holder.tvState.setTag(STATE_START); holder.llDownload.setOnClickListener(listener); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (onItemClickListener != null) { onItemClickListener.onItemClick(position); } } }); if (TasksManager.getImpl().isReady()) { final int status = TasksManager.getImpl().getStatus(id, path); if (status == FileDownloadStatus.pending || status == FileDownloadStatus.started || status == FileDownloadStatus.connected) { AppLogUtils.e("onBindHolder----"+"updateDownloading--------"); // start task, but file not created yet holder.updateDownloading(status, TasksManager.getImpl().getSoFar(id) , TasksManager.getImpl().getTotal(id)); } else if (!new File(path).exists() && !new File(FileDownloadUtils.getTempPath(path)).exists()) { // not exist file AppLogUtils.e("onBindHolder----"+"updateNotDownloaded--------"); holder.updateNotDownloaded(status, 0, 0); } else if (TasksManager.getImpl().isDownloaded(status)) { // already downloaded and exist AppLogUtils.e("onBindHolder----"+"updateDownloaded--------"); holder.updateDownloaded(); } else if (status == FileDownloadStatus.progress) { AppLogUtils.e("onBindHolder----"+"updateDownloading--------"); // downloading holder.updateDownloading(status, TasksManager.getImpl().getSoFar(id) , TasksManager.getImpl().getTotal(id)); } else { // not start AppLogUtils.e("onBindHolder----"+"updateNotDownloaded--------"); holder.updateNotDownloaded(status, TasksManager.getImpl().getSoFar(id) , TasksManager.getImpl().getTotal(id)); } } else { //加载中... AppLogUtils.e("onBindHolder----"+"加载中--------"); } }
Example 5
Source File: DialogListAdapter.java From YCAudioPlayer with Apache License 2.0 | 4 votes |
@SuppressLint("DefaultLocale") @Override public void updateDownloading(int status, long sofar, long total) { AppLogUtils.e("ViewHolder----"+"updateDownloading--------"); final float percent = sofar / (float) total; circlePb.setProgress((int) (percent * 100)); switch (status) { //排队中 case FileDownloadStatus.pending: ivDownload.setBackgroundResource(R.drawable.icon_cache_download); AppLogUtils.e("ViewHolder----"+"排队中--------"); tvState.setTag(STATE_START); tvState.setText("排队中"); break; //开始下载 case FileDownloadStatus.started: ivDownload.setBackgroundResource(R.drawable.icon_cache_download); AppLogUtils.e("ViewHolder----"+"开始下载--------"); tvState.setTag(STATE_START); tvState.setText("开始下载"); break; //链接中 case FileDownloadStatus.connected: ivDownload.setBackgroundResource(R.drawable.icon_cache_download); AppLogUtils.e("ViewHolder----"+"链接中--------"); tvState.setTag(STATE_START); tvState.setText("链接中"); break; //下载中 case FileDownloadStatus.progress: ivDownload.setBackgroundResource(R.drawable.icon_cache_play); AppLogUtils.e("ViewHolder----"+"下载中--------"); tvState.setTag(STATE_PAUSE); tvState.setText("下载中"); break; //默认 default: ivDownload.setBackgroundResource(R.drawable.icon_cache_play); AppLogUtils.e("ViewHolder----"+"默认--------"); tvState.setTag(STATE_PAUSE); tvState.setText("默认"); break; } }
Example 6
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 7
Source File: MessageSnapshot.java From okdownload with Apache License 2.0 | 4 votes |
@Override public byte getStatus() { return FileDownloadStatus.started; }
Example 8
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 9
Source File: TasksManagerDemoActivity.java From FileDownloader with Apache License 2.0 | 4 votes |
@Override public void onBindViewHolder(TaskItemViewHolder holder, int position) { final TasksManagerModel model = TasksManager.getImpl().get(position); holder.update(model.getId(), position); holder.taskActionBtn.setTag(holder); holder.taskNameTv.setText(model.getName()); TasksManager.getImpl() .updateViewHolder(holder.id, holder); holder.taskActionBtn.setEnabled(true); if (TasksManager.getImpl().isReady()) { final int status = TasksManager.getImpl().getStatus(model.getId(), model.getPath()); if (status == FileDownloadStatus.pending || status == FileDownloadStatus.started || status == FileDownloadStatus.connected) { // start task, but file not created yet holder.updateDownloading(status, TasksManager.getImpl().getSoFar(model.getId()) , TasksManager.getImpl().getTotal(model.getId())); } else if (!new File(model.getPath()).exists() && !new File(FileDownloadUtils.getTempPath(model.getPath())).exists()) { // not exist file holder.updateNotDownloaded(status, 0, 0); } else if (TasksManager.getImpl().isDownloaded(status)) { // already downloaded and exist holder.updateDownloaded(); } else if (status == FileDownloadStatus.progress) { // downloading holder.updateDownloading(status, TasksManager.getImpl().getSoFar(model.getId()) , TasksManager.getImpl().getTotal(model.getId())); } else { // not start holder.updateNotDownloaded(status, TasksManager.getImpl().getSoFar(model.getId()) , TasksManager.getImpl().getTotal(model.getId())); } } else { holder.taskStatusTv.setText(R.string.tasks_manager_demo_status_loading); holder.taskActionBtn.setEnabled(false); } }
Example 10
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 11
Source File: MessageSnapshot.java From FileDownloader with Apache License 2.0 | 4 votes |
@Override public byte getStatus() { return FileDownloadStatus.started; }
Example 12
Source File: DownloadTaskHunter.java From FileDownloader with Apache License 2.0 | 4 votes |
@Override public void onIng() { if (FileDownloadMonitor.isValid() && getStatus() == FileDownloadStatus.started) { FileDownloadMonitor.getMonitor().onTaskStarted(mTask.getRunningTask().getOrigin()); } }