added current view variable to configurations

This commit is contained in:
paul-loedige 2021-01-07 19:15:33 +01:00
parent a0f05e4a2f
commit c94331eeaf
2 changed files with 28 additions and 0 deletions

View File

@ -1,5 +1,6 @@
{
"address": "192.168.1.100",
"port" : 8080,
"currentView" : "",
"favorites" : [ ]
}

View File

@ -117,6 +117,18 @@ public class ConfigurationHandler implements IFAVORITES {
return deviceName;
}
//cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
public String getCurrentView() {
return configurations.getCurrentView();
}
//cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
public String setCurrentView(String viewName) {
configurations.setCurrentView(viewName);
writeJsonFile();
return getCurrentView();
}
//endregion
//region private methods
@ -136,6 +148,7 @@ public class ConfigurationHandler implements IFAVORITES {
JSONObject jsonObject = new JSONObject(jsonData);
configurations.setAddress(jsonObject.getString("address"));
configurations.setPort(jsonObject.getInt("port"));
configurations.setCurrentView(jsonObject.getString("currentView"));
List<String> favoriteNames = new ArrayList<>();
JSONArray favorites = jsonObject.getJSONArray("favorites");
for (int i = 0; i < favorites.length(); i++) {
@ -192,6 +205,19 @@ public class ConfigurationHandler implements IFAVORITES {
/** The names of the favorite devices. **/
private List<String> favoriteNames = new ArrayList<>();
//cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
public String getCurrentView() {
return currentView;
}
//cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
public void setCurrentView(String currentView) {
this.currentView = currentView;
}
/** The name of the current view. **/
private String currentView = "";
/**
* Getter for the address variable.
* @return the address of the raspberry
@ -254,6 +280,7 @@ public class ConfigurationHandler implements IFAVORITES {
return "{\n"
+ "\t\"address\":\"" + address + "\",\n"
+ "\t\"port\":\"" + port + "\",\n"
+ "\t\"currentView\":\"" + currentView + "\",\n"
+ "\t\"favorites\":" + favoriteNamesString.toString() + "\n"
+ "}";
}