GithubHelp home page GithubHelp logo

jacksgong / filedownloader-okhttp3-connection Goto Github PK

View Code? Open in Web Editor NEW
117.0 6.0 7.0 77 KB

The FileDownloadConnection implemented with the okhttp3

License: Apache License 2.0

Java 100.00%
okhttp filedownloader connection filedownloader-component filedownloader-okhttp3-connection

filedownloader-okhttp3-connection's Introduction

FileDownloader OkHttp3 Connection

A connection implemented with the OkHttp3 for FileDownloader.

Download Build Status

Usage

The simplest way to enable the connection with the okHttp3 for FileDownloader:

// Init the FileDownloader with the OkHttp3Connection.Creator.
FileDownloader.init(context, new DownloadMgrInitialParams.InitCustomMaker()
                .connectionCreator(new OkHttp3Connection.Creator()));

Alternatively, If you want to customize the OkHttp3Client, you can provide the OkHttpClient.Builder when create the OkHttp3Connection.Creator:

// Enable the okHttp3 connection with the customized okHttp client builder.
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.connectTimeout(20_000, TimeUnit.SECONDS); // customize the value of the connect timeout.

// Init the FileDownloader with the OkHttp3Connection.Creator.
FileDownloader.setupOnApplicationOnCreate(this)
        .connectionCreator(new OkHttp3Connection.Creator(builder));

Installation

Adding the following dependency to your build.gradle file:

dependencies {
    compile 'cn.dreamtobe.filedownloader:filedownloader-okhttp3-connection:1.1.0'
}

Okhttp3 Versioin and FileDownloader Version

If you want to dependency another newer version of Okhttp3 or FileDownloader, just feel free add on your dependencies block, such as:

In this case, gradle will choose newer version dependency library instead.

dependencies {
  compile'cn.dreamtobe.filedownloader:filedownloader-okhttp3-connection:1.1.0'
  compile 'com.squareup.okhttp3:okhttp:3.9.1'
  compile 'com.liulishuo.filedownloader:library:1.7.0'
}

If you want to dependency another lower version of Okhttp3 or FileDownloader, you need to exclude it from filedownloader-okhttp3-connection first, then add it, such as:

dependencies {
  compile('cn.dreamtobe.filedownloader:filedownloader-okhttp3-connection:1.1.0') {
      exclude module: 'okhttp'
      exclude group: 'com.liulishuo.filedownloader', module: 'library'
  }

  compile 'com.squareup.okhttp3:okhttp:3.4.2'
  compile 'com.liulishuo.filedownloader:library:1.6.9'
}

Finally, please don't forget to use ./gradlew dependencies to check out the final relationship of dependencies on your project.

Proguard Rule

because of okhttp, you need to add below proguard-rules to your project:

-dontwarn okhttp3.*
-dontwarn okio.**

License

Copyright (C) 2016 Jacksgong(blog.dreamtobe.cn)

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.

filedownloader-okhttp3-connection's People

Contributors

jacksgong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

filedownloader-okhttp3-connection's Issues

use okhttp3 connection has a error

when i use okhttp3client ,it's has a error .
log like this
error exception =Can't rename the temp downloaded file(/mnt/sdcard/Download/a42e8385998837e8c6814ff862ed717b.apk.temp) to the target file(/mnt/sdcard/Download/a42e8385998837e8c6814ff862ed717b.apk)

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.