|
|
|
|
@ -139,12 +139,17 @@ public class LiveConfig { |
|
|
|
|
|
|
|
|
|
public void parseConfig(JsonObject object, Callback callback) { |
|
|
|
|
if (!object.has("lives")) return; |
|
|
|
|
for (JsonElement element : Json.safeListElement(object, "lives")) parse(Live.objectFrom(element).check()); |
|
|
|
|
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); |
|
|
|
|
if (callback != null) App.post(callback::success); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void add(Live live) { |
|
|
|
|
if (!lives.contains(live)) lives.add(live); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void bootLive() { |
|
|
|
|
LiveActivity.start(App.activity()); |
|
|
|
|
Setting.putBootLive(false); |
|
|
|
|
@ -154,11 +159,6 @@ public class LiveConfig { |
|
|
|
|
parseConfig(object, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void parse(Live live) { |
|
|
|
|
if (live.getName().equals(config.getHome())) setHome(live); |
|
|
|
|
if (!lives.contains(live)) lives.add(live); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setKeep(List<Group> items) { |
|
|
|
|
List<String> key = new ArrayList<>(); |
|
|
|
|
for (Keep keep : Keep.getLive()) key.add(keep.getKey()); |
|
|
|
|
|