Skip to content

Commit

Permalink
优化版本更新的处理
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexiangjys committed Feb 4, 2020
1 parent 9ab2f36 commit cadeb65
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
Binary file modified apk/xuidemo.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/java/com/xuexiang/xuidemo/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/
public final class Utils {

public final static String mUpdateUrl = "https://raw.githubusercontent.com/xuexiangjys/XUI/master/jsonapi/update_api.json";
public final static String mUpdateUrl = "https://gitee.com/xuexiangjys/XUI/raw/master/jsonapi/update_api.json";

private Utils() {
throw new UnsupportedOperationException("u can't instantiate me...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void cancelDownload() {
super.cancelDownload();
if (mIsStartDownload) {
mIsStartDownload = false;
ActivityUtils.startActivity(UpdateTipDialog.class);
UpdateTipDialog.show("");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ public void onFailure(UpdateError error) {
if (mNeedErrorTip) {
XToastUtils.toast(error.toString());
}
if (error.getCode() == UpdateError.ERROR.DOWNLOAD_FAILED) {
UpdateTipDialog.show("Github被墙无法下载,是否考虑切换蒲公英下载[密码:xuexiangjys]?");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
package com.xuexiang.xuidemo.utils.update;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.xuexiang.xui.widget.dialog.DialogLoader;
import com.xuexiang.xuidemo.utils.Utils;
import com.xuexiang.xupdate.XUpdate;

/**
* 版本更新提示弹窗
Expand All @@ -34,12 +37,30 @@
*/
public class UpdateTipDialog extends AppCompatActivity implements DialogInterface.OnDismissListener {

public static final String KEY_CONTENT = "com.xuexiang.xuidemo.utils.update.KEY_CONTENT";

/**
* 显示版本更新重试提示弹窗
*
* @param content
*/
public static void show(String content) {
Intent intent = new Intent(XUpdate.getContext(), UpdateTipDialog.class);
intent.putExtra(KEY_CONTENT, content);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
XUpdate.getContext().startActivity(intent);
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

String content = getIntent().getStringExtra(KEY_CONTENT);
if (TextUtils.isEmpty(content)) {
content = "Github下载速度太慢了,是否考虑切换蒲公英下载[密码:xuexiangjys]?";
}

DialogLoader.getInstance().showConfirmDialog(this, "Github下载速度太慢了,是否考虑切换蒲公英下载?", "是", (dialog, which) -> {
DialogLoader.getInstance().showConfirmDialog(this, content, "是", (dialog, which) -> {
dialog.dismiss();
Utils.goWeb(UpdateTipDialog.this, "https://www.pgyer.com/XUIDemo");
}, "否")
Expand Down
4 changes: 2 additions & 2 deletions jsonapi/update_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"UploadTime": "2020-01-10 00:00:00",
"ModifyContent": "\r\n1、新增多个按钮特效组件。\n2、优化了部分组件功能。\n3、新增组件全局搜索功能。",
"DownloadUrl": "https://raw.githubusercontent.com/xuexiangjys/XUI/master/apk/xuidemo.apk",
"ApkSize": 11878,
"ApkMd5": "493145EA301FAA5967760CC6A671A30B"
"ApkSize": 11306,
"ApkMd5": "0CECC733A63F993547E6B0564DC86B66"
}

0 comments on commit cadeb65

Please sign in to comment.