Skip to content
Snippets Groups Projects
Commit 91a1c6bb authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Add audio module to profile on save; Improve error handling

parent 9d788b2e
Branches
Tags
No related merge requests found
package de.tobias.playpad.profile;
import de.thecodelabs.logger.Logger;
import de.thecodelabs.utils.application.App;
import de.thecodelabs.utils.application.ApplicationUtils;
import de.thecodelabs.utils.application.container.PathType;
......@@ -108,19 +109,23 @@ public class Profile {
public void save() throws IOException {
ref.getRequestedModules().clear();
PlayPadPlugin.getImplementation().getSettingsListener().forEach(l ->
{
App app = ApplicationUtils.getApplication();
Path root = app.getPath(PathType.CONFIGURATION, ref.getFileName());
if (Files.notExists(root)) {
Files.createDirectories(root);
}
PlayPadPlugin.getImplementation().getSettingsListener().forEach(l -> {
try {
l.onSave(this);
} catch (Exception ex) {
ex.printStackTrace();
Logger.error(ex);
}
});
App app = ApplicationUtils.getApplication();
Path root = app.getPath(PathType.CONFIGURATION, ref.getFileName());
if (Files.notExists(root))
Files.createDirectories(root);
// Add audio settings to module list
ref.addRequestedModule(PlayPadPlugin.getRegistryCollection().getAudioHandlers().getModule(profileSettings.getAudioClass()));
profileSettings.save(getProfilePath(PROFILE_SETTINGS_XML));
mappings.save(getProfilePath(MAPPING_XML));
......
package de.tobias.playpad.profile;
import de.thecodelabs.logger.Logger;
import de.thecodelabs.storage.settings.UserDefaults;
import de.thecodelabs.storage.settings.annotation.Key;
import de.tobias.playpad.PlayPadPlugin;
......@@ -24,11 +25,10 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
public class ProfileSettings {
private static final long serialVersionUID = 1L;
@Key
private BooleanProperty lockedProperty = new SimpleBooleanProperty(false);
......@@ -42,7 +42,7 @@ public class ProfileSettings {
@Key
private String audioClass = PlayPadPlugin.getRegistryCollection().getAudioHandlers().getDefaultID();
@Key
private HashMap<String, Object> audioUserInfo = new HashMap<>();
private Map<String, Object> audioUserInfo = new HashMap<>();
// Layout
@Key
......@@ -65,7 +65,7 @@ public class ProfileSettings {
@Key
private Fade fade = new Fade();
@Key
private TimeMode player_timeDisplayMode = TimeMode.REST;
private TimeMode playerTimeDisplayMode = TimeMode.REST;
public boolean isLocked() {
return lockedProperty.get();
......@@ -113,14 +113,14 @@ public class ProfileSettings {
}
public TimeMode getPlayerTimeDisplayMode() {
return player_timeDisplayMode;
return playerTimeDisplayMode;
}
public String getAudioClass() {
return audioClass;
}
public HashMap<String, Object> getAudioUserInfo() {
public Map<String, Object> getAudioUserInfo() {
return audioUserInfo;
}
......@@ -161,8 +161,8 @@ public class ProfileSettings {
this.fade = fade;
}
public void setPlayerTimeDisplayMode(TimeMode player_timeDisplayMode) {
this.player_timeDisplayMode = player_timeDisplayMode;
public void setPlayerTimeDisplayMode(TimeMode playerTimeDisplayMode) {
this.playerTimeDisplayMode = playerTimeDisplayMode;
}
public void setAudioClass(String audioClass) {
......@@ -242,7 +242,7 @@ public class ProfileSettings {
TimeMode timeMode = TimeMode.valueOf(root.element(TIME_DISPLAY_ELEMENT).getStringValue());
profileSettings.setPlayerTimeDisplayMode(timeMode);
} catch (Exception e) {
e.printStackTrace();
Logger.error(e);
}
}
......@@ -286,7 +286,7 @@ public class ProfileSettings {
root.addElement(WARNING_ELEMENT).addText(warningTime.toString());
fade.save(root.addElement(FADE_ELEMENT));
root.addElement(TIME_DISPLAY_ELEMENT).addText(player_timeDisplayMode.name());
root.addElement(TIME_DISPLAY_ELEMENT).addText(playerTimeDisplayMode.name());
root.addElement(MULTIPLE_PLAYER_ELEMENT).addText(String.valueOf(multiplePlayer));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment