Giter Site home page Giter Site logo

leejouher / downloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from justson/downloader

0.0 0.0 0.0 16.32 MB

Powerful and flexible Android file downloader

Home Page: https://github.com/Justson/Downloader

License: Apache License 2.0

Java 100.00%

downloader's Introduction

Downloader

Downloader 是一个非常轻巧以及功能强大快速下载库,只有50KB 左右大小,对于大多数应用来说,性价比最高的一个下载库, Downloader 提供的API更简单、轻量且Downloader提供同步下载,系统通知进度等功能。

预览图

特性

  • 支持串行,多线程并行下载
  • 支持断点续传
  • 支持分块传输
  • 支持系统通知进度
  • 支持同步,异步下载
  • 支持自义定路径
  • 支持添加请求头
  • 支持超时配置
  • 提供简易的Api
  • 支持重定向下载
  • 支持进度回调
  • 重试次数配置
  • 支持下载APK文件完成后自动安装
  • 支持暂停,恢复下载等操作

下载

allprojects {
	repositories {
			...
			maven { url 'https://jitpack.io' }
	}
}
  • Support

     implementation 'com.github.Justson:Downloader:v5.0.0' 
  • Androidx

     implementation 'com.github.Justson:Downloader:v5.0.0-androidx'

例子

同步

File file = DownloadImpl.getInstance(getApplicationContext())
				.url("http://shouji.360tpcdn.com/170918/93d1695d87df5a0c0002058afc0361f1/com.ss.android.article.news_636.apk")
				.get();

异步

DownloadImpl.getInstance(getApplicationContext())
                .url("http://shouji.360tpcdn.com/170918/f7aa8587561e4031553316ada312ab38/com.tencent.qqlive_13049.apk")
                .enqueue();

进度监听

DownloadImpl.getInstance(getApplicationContext())
		.target(new File(this.getExternalCacheDir(), "com.ss.android.article.news_636.apk"))
		.setUniquePath(false)
		.setForceDownload(true)
.url("http://shouji.360tpcdn.com/170918/93d1695d87df5a0c0002058afc0361f1/com.ss.android.article.news_636.apk")
		.enqueue(new DownloadListenerAdapter() {
					@Override
					public void onStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength, Extra extra) {
						super.onStart(url, userAgent, contentDisposition, mimetype, contentLength, extra);
					}

					@Override
					public void onProgress(String url, long downloaded, long length, long usedTime) {
						super.onProgress(url, downloaded, length, usedTime);
						Log.i(TAG, " progress:" + downloaded + " url:" + url);
					}

					@Override
					public boolean onResult(Throwable throwable, Uri path, String url, Extra extra) {
						Log.i(TAG, " path:" + path + " url:" + url + " length:" + new File(path.getPath()).length());
						return super.onResult(throwable, path, url, extra);
					}
		});

默认的文件目录

/data/data/com.download.sample(packagename)/cache/download/private/filename.jpg
/data/data/com.download.sample(packagename)/cache/download/public/filename.jpg

downloader's People

Contributors

justson avatar lwkwww avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.