Giter Club home page Giter Club logo

downloadmanager's Introduction

DownloadManager

一个"善变"的下载库

介绍

DownloadManager是一个支持切换多种下载库的文件下载框架,支持多任务下载

  • 随心切换下载库,目前只支持OkHttp,后续会支持Async Http和HttpUrlConnection
  • 自定义下载库:实现Downloader接口实现自己的下载库
  • 多个下载监听器选择:AlertDownloadListener,后续会增加更多
  • 自定义下载监听器:实现DowaloadListtener接口实现自己的下载监听器

使用

首先,在AndroidManifest.xml增加两个权限:网络权限和存储读写权限

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

然后引入 Maven:

<dependency>
<groupId>xyz.shaohui.downloadmanager</groupId>
<artifactId>downloadmanager</artifactId>
<version>0.5.0</version>
<type>pom</type>
</dependency>

Gradle: compile 'xyz.shaohui.downloadmanager:downloadmanager:0.5.0'

Demo

	DownloadManager manager = new DownloadManager();  //初始化DownloadManager
    AlertDownloadListener listener = new AlertDownloadListener.Builder(this)  // 新建一个DownloadListener
            .showFileSize(true)
            .build();
    manager.download(url, fileUri, listener);  // 开始一个下载任务

Demo

TODO

  • 暂停任务

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.