Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
teprinciple committed Jun 8, 2019
1 parent cd761af commit 729524f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion UpdateAppUtils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 18 additions & 4 deletions UpdateAppUtils/src/main/java/activity/UpdateAppActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -81,6 +82,10 @@ private void initView() {

}

@Override
public void onBackPressed() {
//super.onBackPressed();
}

private void initOperation() {

Expand Down Expand Up @@ -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);
Expand All @@ -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("更新下载中...");
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion updateapputils/src/main/java/util/DownloadAppUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 729524f

Please # to comment.