Fix config save bug

fongmi
jhengazuki 1 month ago
parent 9de4a3edc0
commit bb34b20a48
  1. 9
      app/src/main/java/com/fongmi/android/tv/api/config/LiveConfig.java
  2. 11
      app/src/main/java/com/fongmi/android/tv/api/config/VodConfig.java
  3. 2
      app/src/main/java/com/fongmi/android/tv/model/LiveViewModel.java
  4. 2
      app/src/main/java/com/fongmi/android/tv/model/SiteViewModel.java

@ -177,6 +177,7 @@ public class LiveConfig {
try {
initLive(object);
initOther(object);
config.json(object.toString()).update();
} catch (Throwable e) {
e.printStackTrace();
} finally {
@ -317,10 +318,10 @@ public class LiveConfig {
setHome(home, false);
}
private void setHome(Live home, boolean check) {
this.home = home;
this.home.setActivated(true);
config.home(home.getName()).update();
private void setHome(Live live, boolean check) {
home = live;
home.setActivated(true);
config.home(home.getName()).save();
for (Live item : getLives()) item.setActivated(home);
if (App.activity() != null && App.activity() instanceof LiveActivity) return;
if (check) if (home.isBoot() || Setting.isBootLive()) App.post(this::bootLive);

@ -41,7 +41,6 @@ public class VodConfig {
private List<String> flags;
private List<Parse> parses;
private ExecutorService executor;
private boolean loadLive;
private static class Loader {
@ -193,7 +192,7 @@ public class VodConfig {
private void initLive(JsonObject object) {
Config temp = Config.find(config, 1).save();
boolean sync = LiveConfig.get().needSync(config.getUrl());
if (sync) LiveConfig.get().clear().config(temp).parse(object);
if (sync) LiveConfig.get().clear().config(temp.update()).parse(object);
}
private void initParse(JsonObject object) {
@ -325,9 +324,9 @@ public class VodConfig {
for (Parse item : getParses()) item.setActivated(parse);
}
public void setHome(Site home) {
this.home = home;
this.home.setActivated(true);
public void setHome(Site site) {
home = site;
home.setActivated(true);
config.home(home.getKey()).save();
for (Site item : getSites()) item.setActivated(home);
}
@ -336,6 +335,6 @@ public class VodConfig {
this.wall = wall;
boolean sync = !TextUtils.isEmpty(wall) && WallConfig.get().needSync(wall);
Config temp = Config.find(wall, config.getName(), 2).save();
if (sync) WallConfig.get().config(temp);
if (sync) WallConfig.get().config(temp.update());
}
}

@ -64,7 +64,7 @@ public class LiveViewModel extends ViewModel {
this.url = new MutableLiveData<>();
this.formatTime = new ArrayList<>();
this.futures = new EnumMap<>(TaskType.class);
this.executor = Executors.newFixedThreadPool(4);
this.executor = Executors.newFixedThreadPool(2);
this.formatDate = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
this.formatTime.add(new SimpleDateFormat("yyyy-MM-ddHH:mm", Locale.getDefault()));
this.formatTime.add(new SimpleDateFormat("yyyy-MM-ddHH:mm:ss", Locale.getDefault()));

@ -51,7 +51,7 @@ public class SiteViewModel extends ViewModel {
private Future<Result> future;
public SiteViewModel() {
executor = Executors.newFixedThreadPool(2);
executor = Executors.newSingleThreadExecutor();
episode = new MutableLiveData<>();
result = new MutableLiveData<>();
player = new MutableLiveData<>();

Loading…
Cancel
Save