From 1c1aa6bba5df3dda903fe96420be096e71d78195 Mon Sep 17 00:00:00 2001 From: FongMi Date: Sun, 26 Nov 2023 00:44:02 +0800 Subject: [PATCH] Fix bug --- .../com/fongmi/android/tv/api/LiveConfig.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/fongmi/android/tv/api/LiveConfig.java b/app/src/main/java/com/fongmi/android/tv/api/LiveConfig.java index 5a7f6f397..d7bf6c8fb 100644 --- a/app/src/main/java/com/fongmi/android/tv/api/LiveConfig.java +++ b/app/src/main/java/com/fongmi/android/tv/api/LiveConfig.java @@ -93,7 +93,7 @@ public class LiveConfig { if (isEmpty()) load(new Callback()); } - public void load(Callback callback) { + private void load(Callback callback) { new Thread(() -> loadConfig(callback)).start(); } @@ -121,7 +121,7 @@ public class LiveConfig { App.post(callback::success); lives.remove(live); lives.add(live.sync()); - setHome(live); + setHome(live, true); } private void checkJson(JsonObject object, Callback callback) { @@ -132,7 +132,7 @@ public class LiveConfig { } } - public void parseDepot(JsonObject object, Callback callback) { + private void parseDepot(JsonObject object, Callback callback) { List items = Depot.arrayFrom(object.getAsJsonArray("urls").toString()); List configs = new ArrayList<>(); for (Depot item : items) configs.add(Config.find(item, 1)); @@ -141,12 +141,11 @@ public class LiveConfig { loadConfig(callback); } - public void parseConfig(JsonObject object, Callback callback) { + private void parseConfig(JsonObject object, Callback callback) { if (!object.has("lives")) return; for (JsonElement element : Json.safeListElement(object, "lives")) add(Live.objectFrom(element).check()); - for (Live live : lives) if (live.getName().equals(config.getHome())) setHome(live); - if (home == null) setHome(lives.isEmpty() ? new Live() : lives.get(0)); - if (home.isBoot() || Setting.isBootLive()) App.post(this::bootLive); + for (Live live : lives) if (live.getName().equals(config.getHome())) setHome(live, true); + if (home == null) setHome(lives.isEmpty() ? new Live() : lives.get(0), true); if (callback != null) App.post(callback::success); } @@ -225,9 +224,14 @@ public class LiveConfig { } public void setHome(Live home) { + setHome(home, false); + } + + private void setHome(Live home, boolean check) { this.home = home; this.home.setActivated(true); config.home(home.getName()).update(); for (Live item : lives) item.setActivated(home); + if (check) if (home.isBoot() || Setting.isBootLive()) App.post(this::bootLive); } }