1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

Pebble: simplify AppMessageHandler

This commit is contained in:
Andreas Shimokawa 2017-01-24 18:38:26 +01:00
parent 3dd058cf81
commit 3233432ee1
2 changed files with 17 additions and 67 deletions

View File

@ -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<String> 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);
}

View File

@ -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<String> 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);
}