1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

AndroidGCS: Fix the getDouble() method for enum fields and make the UAVO

browser properly initialize enums in editing mode
This commit is contained in:
James Cotton 2012-08-05 14:38:29 -05:00
parent f04930b8cf
commit ee54ca47f4
2 changed files with 9 additions and 1 deletions

View File

@ -91,6 +91,7 @@ public class ObjectEditView extends GridLayout {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item);
adapter.addAll(field.getOptions());
((Spinner) fieldValue).setAdapter(adapter);
((Spinner) fieldValue).setSelection((int) field.getDouble(idx));
break;
}

View File

@ -390,7 +390,14 @@ public class UAVObjectField {
}
public double getDouble() { return getDouble(0); };
public double getDouble(int index) {
@SuppressWarnings("unchecked")
public double getDouble(int index) {
switch (type) {
case ENUM:
return ((List<Byte>)data).get(index);
default:
break;
}
return ((Number) getValue(index)).doubleValue();
}