Java Code Examples for com.liulishuo.filedownloader.BaseDownloadTask#start()
The following examples show how to use
com.liulishuo.filedownloader.BaseDownloadTask#start() .
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: CacheDownloadingAdapter.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { if (v.getTag() == null) { return; } AppLogUtils.e("listener----"+"--------"); int imgResId = (int) holder.ivDownload.getTag(); TasksManagerModel model = list.get(holder.position); String path = model.getPath(); String url = model.getUrl(); AppLogUtils.e("listener----"+url+ "--------"); switch (imgResId) { case R.drawable.ic_note_btn_play_white: AppLogUtils.e("listener----"+"------开始下载--"); // 开始下载 final BaseDownloadTask task = FileDownloader.getImpl().create(url) .setPath(path) .setCallbackProgressTimes(500) .setListener(new TaskFileDownloadListener()); TasksManager.getImpl().addTaskForViewHolder(task); TasksManager.getImpl().updateViewHolder(holder.id, holder); task.start(); break; case R.drawable.ic_note_btn_pause_white: AppLogUtils.e("listener----"+"------暂停下载--"); // 暂停下载 FileDownloader.getImpl().pause(holder.id); holder.ivDownload.setBackgroundResource(R.drawable.ic_note_btn_play_white); holder.ivDownload.setTag(R.drawable.ic_note_btn_play_white); break; default: break; } }
Example 2
Source File: TasksUtils.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
/** * 开始下载 * @param url 下载链接 */ public static void start(String url , String path){ final BaseDownloadTask task = FileDownloader.getImpl().create(url) .setPath(path) .setCallbackProgressTimes(500) .setListener(new TaskFileDownloadListener()); TasksManager.getImpl().addTaskForViewHolder(task); TasksManager.getImpl().addTask(url,path); task.start(); }
Example 3
Source File: UpdateFragment.java From YCUpdateApp with Apache License 2.0 | 5 votes |
private BaseDownloadTask downApk(String apkUrl, String saveApkPath, FileDownloadListener listener) { BaseDownloadTask baseDownloadTask = FileDownloader .getImpl() .create(apkUrl) .setPath(saveApkPath) .setListener(listener); baseDownloadTask.start(); return baseDownloadTask; }
Example 4
Source File: PhotoViewActivity.java From Simpler with Apache License 2.0 | 5 votes |
@OnClick(R.id.ivSave) void savePic() { String url = mPicUrls.get(mCurPicNum); String path = Constants.Dir.PIC_DIR + File.separator + CommonUtils.getFileNameFromUrl(url); BaseDownloadTask downloadTask = createDownloadTask(mPicUrls.get(mCurPicNum), path, null, false); downloadTask.start(); }
Example 5
Source File: PhotoViewActivity.java From Simpler with Apache License 2.0 | 5 votes |
@OnClick(R.id.ivShare) void sharePic() { String url = mPicUrls.get(mCurPicNum); String path = Constants.Dir.PIC_DIR + File.separator + CommonUtils.getFileNameFromUrl(url); BaseDownloadTask downloadTask = createDownloadTask(mPicUrls.get(mCurPicNum), path, null, true); downloadTask.start(); }
Example 6
Source File: TasksManagerDemoActivity.java From FileDownloader with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { if (v.getTag() == null) { return; } TaskItemViewHolder holder = (TaskItemViewHolder) v.getTag(); CharSequence action = ((TextView) v).getText(); if (action.equals(v.getResources().getString(R.string.pause))) { // to pause FileDownloader.getImpl().pause(holder.id); } else if (action.equals(v.getResources().getString(R.string.start))) { // to start // to start final TasksManagerModel model = TasksManager.getImpl().get(holder.position); final BaseDownloadTask task = FileDownloader.getImpl().create(model.getUrl()) .setPath(model.getPath()) .setCallbackProgressTimes(100) .setListener(taskDownloadListener); TasksManager.getImpl() .addTaskForViewHolder(task); TasksManager.getImpl() .updateViewHolder(holder.id, holder); task.start(); } else if (action.equals(v.getResources().getString(R.string.delete))) { // to delete new File(TasksManager.getImpl().get(holder.position).getPath()).delete(); holder.taskActionBtn.setEnabled(true); holder.updateNotDownloaded(FileDownloadStatus.INVALID_STATUS, 0, 0); } }