diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java index 8b12aa698..37122ec65 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java @@ -11,7 +11,6 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Objects; import java.util.SimpleTimeZone; import java.util.TimeZone; @@ -63,46 +62,17 @@ class AppMessageHandlerMorpheuz extends AppMessageHandler { messageKeys = new HashMap<>(); try { JSONObject appKeys = getAppKeys(); - Iterator appKeysIterator = appKeys.keys(); - while (appKeysIterator.hasNext()) { - String current = appKeysIterator.next(); - int appKey = appKeys.getInt(current); - switch (current) { - case "keyPoint": - keyPoint = appKey; - break; - case "keyCtrl": - keyCtrl = appKey; - break; - case "keyFrom": - keyFrom = appKey; - break; - case "keyTo": - keyTo = appKey; - break; - case "keyBase": - keyBase = appKey; - break; - case "keyVersion": - keyVersion = appKey; - break; - case "keyGoneoff": - keyGoneoff = appKey; - break; - case "keyTransmit": - keyTransmit = appKey; - break; - case "keyAutoReset": - keyAutoReset = appKey; - break; - case "keySnoozes": - keySnoozes = appKey; - break; - case "keyFault": - keyFault = appKey; - break; - } - } + keyPoint = appKeys.getInt("keyPoint"); + keyCtrl = appKeys.getInt("keyCtrl"); + keyFrom = appKeys.getInt("keyFrom"); + keyTo = appKeys.getInt("keyTo"); + keyBase = appKeys.getInt("keyBase"); + keyVersion = appKeys.getInt("keyVersion"); + keyGoneoff = appKeys.getInt("keyGoneoff"); + keyTransmit = appKeys.getInt("keyTransmit"); + keyAutoReset = appKeys.getInt("keyAutoReset"); + keySnoozes = appKeys.getInt("keySnoozes"); + keyFault = appKeys.getInt("keyFault"); } catch (IOException | JSONException e) { GB.toast("There was an error accessing the watchface configuration.", Toast.LENGTH_LONG, GB.ERROR); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerTrekVolle.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerTrekVolle.java index becf1a3c1..6d28fa8e3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerTrekVolle.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerTrekVolle.java @@ -9,7 +9,6 @@ import org.json.JSONObject; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.UUID; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; @@ -32,31 +31,12 @@ class AppMessageHandlerTrekVolle extends AppMessageHandler { messageKeys = new HashMap<>(); try { JSONObject appKeys = getAppKeys(); - Iterator appKeysIterator = appKeys.keys(); - while (appKeysIterator.hasNext()) { - String current = appKeysIterator.next(); - int appKey = appKeys.getInt(current); - switch (current) { - case "WEATHER_TEMPERATURE": - MESSAGE_KEY_WEATHER_TEMPERATURE = appKey; - break; - case "WEATHER_CONDITIONS": - MESSAGE_KEY_WEATHER_CONDITIONS = appKey; - break; - case "WEATHER_ICON": - MESSAGE_KEY_WEATHER_ICON = appKey; - break; - case "WEATHER_TEMPERATURE_MIN": - MESSAGE_KEY_WEATHER_TEMPERATURE_MIN = appKey; - break; - case "WEATHER_TEMPERATURE_MAX": - MESSAGE_KEY_WEATHER_TEMPERATURE_MAX = appKey; - break; - case "WEATHER_LOCATION": - MESSAGE_KEY_WEATHER_LOCATION = appKey; - break; - } - } + MESSAGE_KEY_WEATHER_TEMPERATURE = appKeys.getInt("WEATHER_TEMPERATURE"); + MESSAGE_KEY_WEATHER_CONDITIONS = appKeys.getInt("WEATHER_CONDITIONS"); + MESSAGE_KEY_WEATHER_ICON = appKeys.getInt("WEATHER_ICON"); + MESSAGE_KEY_WEATHER_TEMPERATURE_MIN = appKeys.getInt("WEATHER_TEMPERATURE_MIN"); + MESSAGE_KEY_WEATHER_TEMPERATURE_MAX = appKeys.getInt("WEATHER_TEMPERATURE_MAX"); + MESSAGE_KEY_WEATHER_LOCATION = appKeys.getInt("WEATHER_LOCATION"); } catch (IOException | JSONException e) { GB.toast("There was an error accessing the watchface configuration.", Toast.LENGTH_LONG, GB.ERROR); }