From 729524fe44b13e01e769fa9e7736d37699ebf630 Mon Sep 17 00:00:00 2001 From: teprinciple Date: Sat, 8 Jun 2019 22:21:07 +0800 Subject: [PATCH] fix bugs --- UpdateAppUtils/build.gradle | 2 +- .../main/java/activity/UpdateAppActivity.java | 22 +++++++++++++++---- .../updateappdemo/KotlinDemoActivity.kt | 2 +- .../updateappdemo/MainActivity.java | 2 +- .../src/main/java/util/DownloadAppUtils.java | 3 ++- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/UpdateAppUtils/build.gradle b/UpdateAppUtils/build.gradle index 7d58b49..531ac95 100644 --- a/UpdateAppUtils/build.gradle +++ b/UpdateAppUtils/build.gradle @@ -41,7 +41,7 @@ dependencies { apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' // This is the library version used when deploying the artifact -version = "1.5.1" +version = "1.5.2" def siteUrl = 'https://github.com/teprinciple/UpdateAppDemo' // 项目的主页 def gitUrl = 'https://github.com/teprinciple/UpdateAppDemo.git' // Git仓库的url diff --git a/UpdateAppUtils/src/main/java/activity/UpdateAppActivity.java b/UpdateAppUtils/src/main/java/activity/UpdateAppActivity.java index 0db10da..ba38ec0 100644 --- a/UpdateAppUtils/src/main/java/activity/UpdateAppActivity.java +++ b/UpdateAppUtils/src/main/java/activity/UpdateAppActivity.java @@ -18,6 +18,7 @@ import android.text.TextUtils; import android.view.View; import android.widget.TextView; +import android.widget.Toast; import customview.ConfirmDialog; import model.UpdateBean; @@ -81,6 +82,10 @@ private void initView() { } + @Override + public void onBackPressed() { + //super.onBackPressed(); + } private void initOperation() { @@ -130,14 +135,13 @@ private void download() { if (updateBean.getDownloadBy() == UpdateAppUtils.DOWNLOAD_BY_APP) { if (isWifiConnected(this)) { - - DownloadAppUtils.download(this, updateBean.getApkPath(), updateBean.getServerVersionName()); + realDownload(); } else { new ConfirmDialog(this, new ConfirmDialog.Callback() { @Override public void callback(int position) { if (position == 1) { - DownloadAppUtils.download(UpdateAppActivity.this, updateBean.getApkPath(), updateBean.getServerVersionName()); + realDownload(); } else { if (updateBean.getForce()) { System.exit(0); @@ -152,7 +156,17 @@ public void callback(int position) { DownloadAppUtils.downloadForWebView(this, updateBean.getApkPath()); } - finish(); + //finish(); + } + + private void realDownload() { + DownloadAppUtils.download(this, updateBean.getApkPath(), updateBean.getServerVersionName()); + if (!updateBean.getForce()) { + Toast.makeText(this,"更新下载中",Toast.LENGTH_SHORT).show(); + finish(); + }else { + content.setText("更新下载中..."); + } } diff --git a/app/src/main/java/com/example/teprinciple/updateappdemo/KotlinDemoActivity.kt b/app/src/main/java/com/example/teprinciple/updateappdemo/KotlinDemoActivity.kt index 8ec95ea..935db2c 100644 --- a/app/src/main/java/com/example/teprinciple/updateappdemo/KotlinDemoActivity.kt +++ b/app/src/main/java/com/example/teprinciple/updateappdemo/KotlinDemoActivity.kt @@ -15,7 +15,7 @@ class KotlinDemoActivity : AppCompatActivity() { } private fun update() { - val apkPath:String = "http://issuecdn.baidupcs.com/issue/netdisk/apk/BaiduNetdisk_7.15.1.apk" + val apkPath:String = "http://issuecdn.baidupcs.com/issue/netdisk/apk/BaiduNetdisk_9.6.63.apk" UpdateAppUtils.from(this) .serverVersionCode(2) .serverVersionName("2.0") diff --git a/app/src/main/java/com/example/teprinciple/updateappdemo/MainActivity.java b/app/src/main/java/com/example/teprinciple/updateappdemo/MainActivity.java index 4e842db..d7cca2e 100644 --- a/app/src/main/java/com/example/teprinciple/updateappdemo/MainActivity.java +++ b/app/src/main/java/com/example/teprinciple/updateappdemo/MainActivity.java @@ -11,7 +11,7 @@ public class MainActivity extends AppCompatActivity { //服务器apk path,这里放了百度云盘的apk 作为测试 - String apkPath = "http://issuecdn.baidupcs.com/issue/netdisk/apk/BaiduNetdisk_7.15.1.apk"; + String apkPath = "http://issuecdn.baidupcs.com/issue/netdisk/apk/BaiduNetdisk_9.6.63.apk"; private int code = 0; @Override diff --git a/updateapputils/src/main/java/util/DownloadAppUtils.java b/updateapputils/src/main/java/util/DownloadAppUtils.java index 38236e0..6f40fa6 100644 --- a/updateapputils/src/main/java/util/DownloadAppUtils.java +++ b/updateapputils/src/main/java/util/DownloadAppUtils.java @@ -5,6 +5,7 @@ import android.net.Uri; import android.os.Environment; import android.util.Log; +import android.widget.Toast; import com.liulishuo.filedownloader.BaseDownloadTask; import com.liulishuo.filedownloader.FileDownloadLargeFileListener; @@ -73,7 +74,7 @@ protected void completed(BaseDownloadTask task) { @Override protected void error(BaseDownloadTask task, Throwable e) { - //Toast.makeText(context, "下载出错", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, "下载出错", Toast.LENGTH_SHORT).show(); } @Override