|
|
|
|
@ -22,7 +22,9 @@ import java.util.concurrent.Executors; |
|
|
|
|
|
|
|
|
|
public class Updater implements View.OnClickListener { |
|
|
|
|
|
|
|
|
|
private static final String URL = "https://raw.githubusercontent.com/FongMi/TV/release/release/leanback.json"; |
|
|
|
|
private static final String DEF = "https://raw.githubusercontent.com/FongMi/TV/release/release/"; |
|
|
|
|
private static final String URL = DEF + BuildConfig.FLAVOR_mode + ".json"; |
|
|
|
|
private static final String APK = DEF + BuildConfig.FLAVOR_mode + "-" + BuildConfig.FLAVOR_api + ".apk"; |
|
|
|
|
private static final String PROXY = "https://ghproxy.com/"; |
|
|
|
|
|
|
|
|
|
private final ExecutorService executor; |
|
|
|
|
@ -62,9 +64,8 @@ public class Updater implements View.OnClickListener { |
|
|
|
|
JSONObject object = new JSONObject(OKHttp.newCall(target).execute().body().string()); |
|
|
|
|
String name = object.optString("name"); |
|
|
|
|
String desc = object.optString("desc"); |
|
|
|
|
String url = object.optString("url"); |
|
|
|
|
int code = object.optInt("code"); |
|
|
|
|
if (retry > 0) url = PROXY + url; |
|
|
|
|
String url = retry > 0 ? PROXY + APK : APK; |
|
|
|
|
if (code <= BuildConfig.VERSION_CODE) FileUtil.clearDir(getApk()); |
|
|
|
|
else FileUtil.write(getApk(), OKHttp.newCall(url).execute().body().bytes()); |
|
|
|
|
if (getApk().exists() && Prefers.getUpdate()) handler.post(() -> checkActivity(name, desc)); |
|
|
|
|
|