Skip to content

Commit

Permalink
修复下载路径是重定向路径不能下载的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
WVector committed Aug 2, 2017
1 parent dd4cce9 commit a9c33b9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

```gradle
dependencies {
compile 'com.qianwen:update-app:3.3.1'
compile 'com.qianwen:update-app:3.3.3'
}
```

Expand All @@ -61,7 +61,7 @@ dependencies {

```gradle
dependencies {
compile 'com.qianwen:update-app-kotlin:1.0.2'
compile 'com.qianwen:update-app-kotlin:1.0.4'
}
```

Expand Down Expand Up @@ -102,6 +102,15 @@ dependencies {

kotlin版本是依赖java版本的,所以java版本的问题kotlin自然修复

V3.3.3

1,修复下载路径是重定向路径不能下载的问题

V3.3.2

1,修复正在下载时,返回桌面报错的问题
[https://github.com/WVector/AppUpdate/issues/14](https://github.com/WVector/AppUpdate/issues/14)

V3.3.1

1,修复对话框外可以点击的问题
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void updateDiy(View view) {
//设置请求方式,默认get
.setPost(false)
//不显示通知栏进度条
.dismissNotificationProgress()
// .dismissNotificationProgress()
//是否忽略版本
// .showIgnoreVersion()
//添加自定义参数,默认version=1.0.0(app的versionName);apkKey=唯一表示(在AndroidManifest.xml配置)
Expand Down Expand Up @@ -133,6 +133,8 @@ protected UpdateAppBean parseJson(String json) {
.setNewVersion(jsonObject.optString("new_version"))
//(必须)下载地址
.setApkFileUrl(jsonObject.optString("apk_file_url"))
//测试下载路径是重定向路径
// .setApkFileUrl("http://openbox.mobilem.360.cn/index/d/sid/3282847")
//(必须)更新内容
.setUpdateLog(jsonObject.optString("update_log"))
//测试内容过度
Expand Down Expand Up @@ -330,6 +332,7 @@ protected UpdateAppBean parseJson(String json) {
.setNewVersion(jsonObject.optString("new_version"))
//(必须)下载地址
.setApkFileUrl(jsonObject.optString("apk_file_url"))

//(必须)更新内容
.setUpdateLog(jsonObject.optString("update_log"))

Expand Down
2 changes: 1 addition & 1 deletion update-app-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ publish {
userOrg = 'qianwen'//bintray.com用户名
groupId = 'com.qianwen'//jcenter上的路径
artifactId = 'update-app-kotlin'//项目名称
publishVersion = '1.0.3'//版本号
publishVersion = '1.0.4'//版本号
desc = 'a library for android version update'
website = 'https://github.com/WVector/AppUpdate'
}
Expand Down
2 changes: 1 addition & 1 deletion update-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ publish {
userOrg = 'qianwen'//bintray.com用户名
groupId = 'com.qianwen'//jcenter上的路径
artifactId = 'update-app'//项目名称
publishVersion = '3.3.2'//版本号
publishVersion = '3.3.3'//版本号
desc = 'a library for android version update'
website = 'https://github.com/WVector/AppUpdate'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,8 @@ private void startDownload(UpdateAppBean updateApp, final DownloadCallback callb
stop(contentText);
return;
}
final String appName = apkUrl.substring(apkUrl.lastIndexOf("/") + 1, apkUrl.length());
String appName = AppUpdateUtils.getApkName(updateApp);

if (!appName.endsWith(".apk")) {
String contentText = "下载包有错误";
stop(contentText);
return;
}
File appDir = new File(updateApp.getTargetPath());
if (!appDir.exists()) {
appDir.mkdirs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.content.FileProvider;
import android.text.TextUtils;
import android.util.DisplayMetrics;
Expand All @@ -41,14 +42,24 @@ public static boolean isWifi(Context context) {
return info != null && info.getType() == ConnectivityManager.TYPE_WIFI;
}


public static File getAppFile(UpdateAppBean updateAppBean) {
String apkUrl = updateAppBean.getApkFileUrl();
final String appName = apkUrl.substring(apkUrl.lastIndexOf("/") + 1, apkUrl.length());
String appName = getApkName(updateAppBean);
return new File(updateAppBean.getTargetPath()
.concat(File.separator + updateAppBean.getNewVersion())
.concat(File.separator + appName));
}

@NonNull
public static String getApkName(UpdateAppBean updateAppBean) {
String apkUrl = updateAppBean.getApkFileUrl();
String appName = apkUrl.substring(apkUrl.lastIndexOf("/") + 1, apkUrl.length());
if (!appName.endsWith(".apk")) {
appName = "temp.apk";
}
return appName;
}

public static boolean appIsDownloaded(UpdateAppBean updateAppBean) {
//md5不为空
//文件存在
Expand Down

0 comments on commit a9c33b9

Please sign in to comment.