Skip to content

Commit

Permalink
文件下载回调bug修复;
Browse files Browse the repository at this point in the history
文件下载名称默认为网络名称
  • Loading branch information
MrZhousf committed Sep 18, 2017
1 parent e533f57 commit effee0f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@
<dependency>
<groupId>com.zhousf.lib</groupId>
<artifactId>okhttp3</artifactId>
<version>2.9.1</version>
<version>2.9.1.1</version>
<type>pom</type>
</dependency>
```
### Gradle
```
compile 'com.zhousf.lib:okhttp3:2.9.1'
compile 'com.zhousf.lib:okhttp3:2.9.1.1'
```
若项目已包含support-annotations或出现support-annotations版本冲突请采用下面方式进行依赖:
```
compile ('com.zhousf.lib:okhttp3:2.9.1'){
compile ('com.zhousf.lib:okhttp3:2.9.1.1'){
exclude(module: 'support-annotations')
}
```
若项目已包含Gson或出现Gson版本冲突请采用下面方式进行依赖:
```
compile ('com.zhousf.lib:okhttp3:2.9.1'){
compile ('com.zhousf.lib:okhttp3:2.9.1.1'){
exclude(module:'gson')
}
```
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {

dependencies {
// compile project(':okhttp3')
compile ('com.zhousf.lib:okhttp3:2.9.1'){
compile ('com.zhousf.lib:okhttp3:2.9.1.1'){
exclude(module:'gson')
}
compile fileTree(include: ['*.jar'], dir: 'libs')
Expand Down
3 changes: 2 additions & 1 deletion okhttp3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
targetSdkVersion rootProject.sdkVersion
minSdkVersion rootProject.minSdkVersion
versionCode 1
versionName "2.9.1"
versionName "2.9.1.1"
}

buildTypes {
Expand All @@ -31,6 +31,7 @@ dependencies {
compile 'com.android.support:support-annotations:23.+'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.google.code.gson:gson:2.8.1'
testCompile 'junit:junit:4.12'
}

//apply from: "bintrayUpload.gradle"
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,18 @@ private long fetchCompletedSize(DownloadFileInfo fileInfo){
String saveFileName = fileInfo.getSaveFileName();
String url = fileInfo.getUrl();
String extension = url.substring(url.lastIndexOf(".") + 1);//扩展名
String originalFileName = "";
if(TextUtils.isEmpty(saveFileName)){
if(url.contains("/") && !url.endsWith("/")){
//文件原名称
saveFileName = url.substring(url.lastIndexOf("/")+1);
originalFileName = url.substring(url.lastIndexOf("/")+1);
originalFileName += "."+extension;
}
}
//文件原名称为空则采用自定义名称
//自定义名称为空时采用文件原名称
if(TextUtils.isEmpty(saveFileName)){
saveFileName = originalFileName;
}else{
saveFileName += "."+extension;
}
String saveFileNameCopy = saveFileName+"["+timeStamp+"]"+"."+extension;
Expand Down

0 comments on commit effee0f

Please sign in to comment.