Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 593f1e7444 | |||
| a4d671b394 |
@@ -6,6 +6,7 @@ import android.view.View;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.fongmi.android.tv.App;
|
||||
import com.fongmi.android.tv.databinding.DialogUpdateBinding;
|
||||
import com.fongmi.android.tv.utils.Download;
|
||||
import com.fongmi.android.tv.utils.FileUtil;
|
||||
@@ -79,13 +80,38 @@ public class Updater implements Download.Callback {
|
||||
|
||||
private void doInBackground(Activity activity) {
|
||||
try {
|
||||
JSONObject object = new JSONObject(OkHttp.string(getJson()));
|
||||
String response = OkHttp.string(getJson());
|
||||
|
||||
// 检查响应是否包含错误信息
|
||||
if (response.contains("rate limit exceeded")) {
|
||||
App.post(() -> Notify.show("检查更新失败:API请求过于频繁,请稍后重试"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.contains("Not Found Project") || response.contains("Not Found")) {
|
||||
App.post(() -> Notify.show("检查更新失败:更新服务暂时不可用"));
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject object = new JSONObject(response);
|
||||
String name = object.optString("name");
|
||||
String desc = object.optString("desc");
|
||||
int code = object.optInt("code");
|
||||
if (need(code, name)) App.post(() -> show(activity, name, desc));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// 添加用户友好的错误提示
|
||||
App.post(() -> {
|
||||
String errorMsg = "检查更新失败";
|
||||
if (e.getMessage() != null && e.getMessage().contains("rate limit")) {
|
||||
errorMsg = "检查更新失败:请求过于频繁,请稍后重试";
|
||||
} else if (e.getMessage() != null && e.getMessage().contains("Not Found")) {
|
||||
errorMsg = "检查更新失败:更新服务暂时不可用";
|
||||
} else {
|
||||
errorMsg = "检查更新失败,请稍后重试";
|
||||
}
|
||||
Notify.show(errorMsg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.view.View;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.fongmi.android.tv.App;
|
||||
import com.fongmi.android.tv.databinding.DialogUpdateBinding;
|
||||
import com.fongmi.android.tv.utils.Download;
|
||||
import com.fongmi.android.tv.utils.FileUtil;
|
||||
@@ -124,6 +125,17 @@ public class Updater implements Download.Callback {
|
||||
String response = OkHttp.string(jsonUrl);
|
||||
Logger.d("Update check response: " + response);
|
||||
|
||||
// 检查响应是否包含错误信息
|
||||
if (response.contains("rate limit exceeded")) {
|
||||
App.post(() -> Notify.show("检查更新失败:API请求过于频繁,请稍后重试"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.contains("Not Found Project") || response.contains("Not Found")) {
|
||||
App.post(() -> Notify.show("检查更新失败:更新服务暂时不可用"));
|
||||
return;
|
||||
}
|
||||
|
||||
JSONObject release = new JSONObject(response);
|
||||
String tagName = release.getString("tag_name");
|
||||
String body = release.getString("body");
|
||||
@@ -148,6 +160,18 @@ public class Updater implements Download.Callback {
|
||||
} catch (Exception e) {
|
||||
Logger.e("Update check failed", e);
|
||||
e.printStackTrace();
|
||||
// 添加用户友好的错误提示
|
||||
App.post(() -> {
|
||||
String errorMsg = "检查更新失败";
|
||||
if (e.getMessage() != null && e.getMessage().contains("rate limit")) {
|
||||
errorMsg = "检查更新失败:请求过于频繁,请稍后重试";
|
||||
} else if (e.getMessage() != null && e.getMessage().contains("Not Found")) {
|
||||
errorMsg = "检查更新失败:更新服务暂时不可用";
|
||||
} else {
|
||||
errorMsg = "检查更新失败,请稍后重试";
|
||||
}
|
||||
Notify.show(errorMsg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ public class Github {
|
||||
public static final String URL = "https://raw.githubusercontent.com/Tosencen/XMBOX/main";
|
||||
public static final String API_URL = "https://api.github.com/repos/Tosencen/XMBOX/releases/latest";
|
||||
|
||||
// 国内镜像地址 - 使用Gitee作为示例,实际应替换为您的镜像地址
|
||||
public static final String CN_URL = "https://gitee.com/tosencen/XMBOX/raw/main";
|
||||
public static final String CN_API_URL = "https://gitee.com/api/v5/repos/tosencen/XMBOX/releases/latest";
|
||||
// 国内镜像地址 - 使用Gitee作为镜像
|
||||
public static final String CN_URL = "https://gitee.com/ochenoktochen/XMBOX/raw/main";
|
||||
public static final String CN_API_URL = "https://gitee.com/api/v5/repos/ochenoktochen/XMBOX/releases/latest";
|
||||
|
||||
// 存储测速结果
|
||||
private static Boolean useCnMirror = null;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user