Skip to content
The FileDownloadConnection implemented with the okhttp3
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea chore: upgrade gradle version Feb 5, 2018
gradle/wrapper chore: upgrade gradle version Feb 5, 2018
src feat: adapter filedownloader 1.7.0 change api to implementation of de… Feb 5, 2018
.gitignore chore: ignore dot files for vscode Jun 30, 2017
.travis.yml chore: fix traivs ci can't find 26 android sdk bugs Feb 5, 2018
AndroidManifest.xml chore: init project Dec 30, 2016
CHANGELOG.md
LICENSE.txt docs: fix typo in the license Dec 31, 2016
README.md chore: upgrade version name(1.0.0->1.1.0) code(1->2) Feb 5, 2018
build.gradle feat: adapter filedownloader 1.7.0 change api to implementation of de… Feb 5, 2018
gradle.properties chore: upgrade version name(1.0.0->1.1.0) code(1->2) Feb 5, 2018
gradlew chore: init project Dec 30, 2016
gradlew.bat chore: init project Dec 30, 2016

README.md

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.
You can’t perform that action at this time.