Skip to content

Commit ecab794

Browse files
committed
添加下载失败重启逻辑
1 parent 460658c commit ecab794

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

updatepluginlib/src/main/java/org/lzh/framework/updatepluginlib/impl/DefaultDownloadNotifier.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,26 @@ public void onDownloadError(Throwable t) {
7171
private void createRestartDialog() {
7272
AlertDialog.Builder builder = new AlertDialog.Builder(ActivityManager.get().topActivity())
7373
.setCancelable(!update.isForced())
74-
.setMessage("下载apk失败。是否重新下载?")
74+
.setTitle("下载apk失败")
75+
.setMessage("是否重新下载?")
76+
.setNeutralButton(update.isForced() ? "退出" : "取消", new DialogInterface.OnClickListener() {
77+
@Override
78+
public void onClick(DialogInterface dialog, int which) {
79+
if (update.isForced()) {
80+
System.exit(0);
81+
Process.killProcess(Process.myPid());
82+
} else {
83+
dialog.dismiss();
84+
}
85+
}
86+
})
7587
.setNegativeButton("确定", new DialogInterface.OnClickListener() {
7688
@Override
7789
public void onClick(DialogInterface dialog, int which) {
7890
restartDownload();
7991
}
8092
});
8193

82-
if (!update.isForced()) {
83-
builder.setNeutralButton("退出", new DialogInterface.OnClickListener() {
84-
@Override
85-
public void onClick(DialogInterface dialog, int which) {
86-
System.exit(0);
87-
Process.killProcess(Process.myPid());
88-
}
89-
});
90-
}
91-
9294
builder.show();
9395
}
9496
}

0 commit comments

Comments
 (0)