Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 729524f

Browse files
committedJun 8, 2019
fix bugs
1 parent cd761af commit 729524f

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed
 

‎UpdateAppUtils/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies {
4141
apply plugin: 'com.github.dcendents.android-maven'
4242
apply plugin: 'com.jfrog.bintray'
4343
// This is the library version used when deploying the artifact
44-
version = "1.5.1"
44+
version = "1.5.2"
4545

4646
def siteUrl = 'https://github.com/teprinciple/UpdateAppDemo' // 项目的主页
4747
def gitUrl = 'https://github.com/teprinciple/UpdateAppDemo.git' // Git仓库的url

‎UpdateAppUtils/src/main/java/activity/UpdateAppActivity.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import android.text.TextUtils;
1919
import android.view.View;
2020
import android.widget.TextView;
21+
import android.widget.Toast;
2122

2223
import customview.ConfirmDialog;
2324
import model.UpdateBean;
@@ -81,6 +82,10 @@ private void initView() {
8182

8283
}
8384

85+
@Override
86+
public void onBackPressed() {
87+
//super.onBackPressed();
88+
}
8489

8590
private void initOperation() {
8691

@@ -130,14 +135,13 @@ private void download() {
130135

131136
if (updateBean.getDownloadBy() == UpdateAppUtils.DOWNLOAD_BY_APP) {
132137
if (isWifiConnected(this)) {
133-
134-
DownloadAppUtils.download(this, updateBean.getApkPath(), updateBean.getServerVersionName());
138+
realDownload();
135139
} else {
136140
new ConfirmDialog(this, new ConfirmDialog.Callback() {
137141
@Override
138142
public void callback(int position) {
139143
if (position == 1) {
140-
DownloadAppUtils.download(UpdateAppActivity.this, updateBean.getApkPath(), updateBean.getServerVersionName());
144+
realDownload();
141145
} else {
142146
if (updateBean.getForce()) {
143147
System.exit(0);
@@ -152,7 +156,17 @@ public void callback(int position) {
152156
DownloadAppUtils.downloadForWebView(this, updateBean.getApkPath());
153157
}
154158

155-
finish();
159+
//finish();
160+
}
161+
162+
private void realDownload() {
163+
DownloadAppUtils.download(this, updateBean.getApkPath(), updateBean.getServerVersionName());
164+
if (!updateBean.getForce()) {
165+
Toast.makeText(this,"更新下载中",Toast.LENGTH_SHORT).show();
166+
finish();
167+
}else {
168+
content.setText("更新下载中...");
169+
}
156170
}
157171

158172

‎app/src/main/java/com/example/teprinciple/updateappdemo/KotlinDemoActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class KotlinDemoActivity : AppCompatActivity() {
1515
}
1616

1717
private fun update() {
18-
val apkPath:String = "http://issuecdn.baidupcs.com/issue/netdisk/apk/BaiduNetdisk_7.15.1.apk"
18+
val apkPath:String = "http://issuecdn.baidupcs.com/issue/netdisk/apk/BaiduNetdisk_9.6.63.apk"
1919
UpdateAppUtils.from(this)
2020
.serverVersionCode(2)
2121
.serverVersionName("2.0")

‎app/src/main/java/com/example/teprinciple/updateappdemo/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class MainActivity extends AppCompatActivity {
1212

1313
//服务器apk path,这里放了百度云盘的apk 作为测试
14-
String apkPath = "http://issuecdn.baidupcs.com/issue/netdisk/apk/BaiduNetdisk_7.15.1.apk";
14+
String apkPath = "http://issuecdn.baidupcs.com/issue/netdisk/apk/BaiduNetdisk_9.6.63.apk";
1515
private int code = 0;
1616

1717
@Override

‎updateapputils/src/main/java/util/DownloadAppUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.net.Uri;
66
import android.os.Environment;
77
import android.util.Log;
8+
import android.widget.Toast;
89

910
import com.liulishuo.filedownloader.BaseDownloadTask;
1011
import com.liulishuo.filedownloader.FileDownloadLargeFileListener;
@@ -73,7 +74,7 @@ protected void completed(BaseDownloadTask task) {
7374

7475
@Override
7576
protected void error(BaseDownloadTask task, Throwable e) {
76-
//Toast.makeText(context, "下载出错", Toast.LENGTH_SHORT).show();
77+
Toast.makeText(context, "下载出错", Toast.LENGTH_SHORT).show();
7778
}
7879

7980
@Override

0 commit comments

Comments
 (0)
Please sign in to comment.