Hide add button from groups fragment when no config is active, made configurations fragment unset active config if the deleted config is the active config

This commit is contained in:
2020-08-28 17:44:05 -05:00
parent e944332b68
commit 5c5b26229c
3 changed files with 14 additions and 1 deletions

View File

@@ -63,7 +63,6 @@ public class Backend {
private Settings settings;
private boolean configChanged, settingsChanged;
private MediaPlayer mediaPlayer;
private SoundPool soundPool;
public static HashMap<String, Object> getStorage() {
return storage;
@@ -145,6 +144,11 @@ public class Backend {
}
public void loadConfig(String name) {
if (name.equals("")) {
config = null;
return;
}
String path = configPath(name);
File file = new File(path);

View File

@@ -60,6 +60,9 @@ public class GroupsFragment extends TimeCraftersFragment {
});
floatingActionButtonAutoHide(actionButton, scrollView);
if (Backend.instance().getConfig() == null) {
actionButton.hide();
}
if (Backend.instance() != null)
this.config = Backend.instance().getConfig();

View File

@@ -111,6 +111,12 @@ public class ConfigurationsFragment extends TimeCraftersFragment {
Backend.instance().deleteConfig(configFile);
Backend.getStorage().remove(deleteActionKey);
if (Backend.instance().getConfig().getName().equals(configFile)) {
Backend.instance().getSettings().config = "";
Backend.instance().saveSettings();
Backend.instance().loadConfig("");
}
ConfigurationsFragment fragment = (ConfigurationsFragment) dialog.getFragmentManager().getPrimaryNavigationFragment();
if (fragment != null) {
fragment.populateConfigFiles();