Git Product home page Git Product logo

filedownloaderfinal's Introduction

FileDownloaderFinal简介

一个Android文件下载管理库,具有扩展性强、简单易用的特性。是基于FileDownloader强大的下载引擎。

如何使用

  • 1、下载FileDownloaderFinal

通过Gradle抓取:

compile 'cn.finalteam:filedownloaderfinal:1.0.7'
  • 在App Application中添加一下配置
private void initDownloaderManager() {
    //下载文件所保存的目录
    File storeFile = StorageUtils.getCacheDirectory(this, false, "FileDownloader");
    if (!storeFile.exists()) {
        storeFile.mkdirs();
    }

    final DownloaderManagerConfiguration.Builder dmBulder = new DownloaderManagerConfiguration.Builder(this)
            .setMaxDownloadingCount(3) //配置最大并行下载任务数,配置范围[1-100]
            .setDbExtField(...) //配置数据库扩展字段
            .setDbVersion(...)//配置数据库版本
            .setDbUpgradeListener(...) //配置数据库更新回调
            .setDownloadStorePath(storeFile.getAbsolutePath()); //配置下载文件存储目录

    //初始化下载管理最好放到线程中去执行防止卡顿情况
    new Thread() {
        @Override
        public void run() {
            super.run();
            DownloaderManager.getInstance().init(dmBulder.build());//必要语句
        }
    }.start();
}
  • 添加任务
DownloaderManager.getInstance().addTask(url);
  • 执行任务
DownloaderManager.getInstance().startTask(downloadId, myFileDownloadListener);
  • 暂停任务
DownloaderManager.getInstance().pauseTask(downloadId);
  • 删除任务
DownloaderManager.getInstance().deleteTask(downloadId);

扩展功能

数据库表扩展

  • 字段扩展

开发者可以添加一些扩展字段来满足业务需求,注意不能包含id,path,url,因为框架内部有定义不得重复

Map<String, String> dbExFeildMap = new HashMap<>();
dbExFeildMap.put("title", "VARCHAR");
dbExFeildMap.put("icon", "VARCHAR");

然后在DownloaderManagerConfiguration.Builder中配置setDbExtField即可

  • 数据库更新

通过改变DownloaderManagerConfiguration.Builder的setDbVersion来修改数据库版本,setDbUpgradeListener来设置数据库更新监听

简单文件下载(不加入下载管理)

private void simpleDownloadFile() {
    String url = "http://cdn6.down.apk.gfan.com/asdf/Pfiles/2015/08/13/1055068_1960ffcc-f122-49e1-b13f-a5b35049e7f5.apk";
    SimpleFileDownloader.downloadFile(url, new FileDownloaderCallback());
}

添加带扩展字段的任务

String url3_apk = "http://cdn6.down.apk.gfan.com/asdf/Pfiles/2015/12/04/1087087_676144cf-a7dc-45df-8b7e-d56ddacf04f9.apk";
String url3_icon = "http://cdn2.image.apk.gfan.com/asdf/PImages/2015/12/04/ldpi_ae934eca-1f51-4e3a-9d26-acd982352f57.png";
String url3_name = "奔跑吧兄弟3-撕名牌大战";
FileDownloaderModel model = new FileDownloaderModel();
model.setUrl(url3_apk);
model.putExtField("icon", url3_icon);
model.putExtField("title", url3_name);//在application中配置的扩展字段名
//添加到下载管理+
DownloaderManager.getInstance().addTask(model);

历史版本

V1.0.6

  • 更新FileDownloader库

V1.0.5

  • 添加下载自动重试

V1.0.4

  • 更新tools库,解决日志循环输出bug

V1.0.3

  • 解决下载文件存放到app cache目录不能访问问题

V1.0.2

  • 解决下载速度不正确问题

V1.0.1

  • 添加下载速度
  • 添加常用方法

V1.0.0

  • 文件下载管理功能
  • 添加数据库表模型可扩展
  • 支持多事件实例回调
  • 添加简单文件下载(不加入下载管理器)
  • 添加下载管理与FileDownloader引擎的事件桥接
  • ……

关于作者

大家如果对项目或项目文档有哪些意见和想法都可以发邮箱或QQ群联系到我

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

filedownloaderfinal's People

Contributors

pengjianbo avatar

Watchers

lixinyang 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.