1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

AndroidGCS: Suppress some warnings related to not implementing the STRING uavfield type properly.

This commit is contained in:
James Cotton 2012-08-26 22:26:34 -05:00
parent f01edc5d72
commit 120f9298b4
2 changed files with 32 additions and 19 deletions

View File

@ -22,22 +22,22 @@ public class ObjectEditView extends GridLayout {
public List<View> fields;
public ObjectEditView(Context context) {
super(context);
super(context);
initObjectEditView();
}
public ObjectEditView(Context context, AttributeSet ats, int defaultStyle) {
public ObjectEditView(Context context, AttributeSet ats, int defaultStyle) {
super(context, ats);
initObjectEditView();
}
public ObjectEditView(Context context, AttributeSet ats) {
public ObjectEditView(Context context, AttributeSet ats) {
super(context, ats);
initObjectEditView();
}
public void initObjectEditView() {
// Set orientation of layout to vertical
// Set orientation of layout to vertical
setOrientation(LinearLayout.VERTICAL);
setColumnCount(2);
fields = new ArrayList<View>();
@ -51,11 +51,11 @@ public class ObjectEditView extends GridLayout {
for (int i = 0; i < field.getNumElements(); i++)
addRow(getContext(), field, i);
}
public void addRow(Context context, UAVObjectField field, int idx) {
int row = getRowCount();
TextView fieldName = new TextView(context);
if(field.getNumElements() == 1) {
fieldName.setText(field.getName());
@ -65,7 +65,7 @@ public class ObjectEditView extends GridLayout {
addView(fieldName, new GridLayout.LayoutParams(spec(row), spec(0)));
View fieldValue = null;
switch(field.getType())
switch(field.getType())
{
case FLOAT32:
fieldValue = new EditText(context);
@ -93,8 +93,16 @@ public class ObjectEditView extends GridLayout {
((Spinner) fieldValue).setAdapter(adapter);
((Spinner) fieldValue).setSelection((int) field.getDouble(idx));
break;
case BITFIELD:
fieldValue = new EditText(context);
((EditText)fieldValue).setText(field.getValue(idx).toString());
((EditText)fieldValue).setInputType(InputType.TYPE_CLASS_NUMBER);
break;
case STRING:
fieldValue = new EditText(context);
((EditText)fieldValue).setText(field.getValue(idx).toString());
}
addView(fieldValue, new GridLayout.LayoutParams(spec(row), spec(1)));
fields.add(fieldValue);
}

View File

@ -578,6 +578,12 @@ public class UAVObjectField {
((ArrayList<Byte>) data).add((byte) 0);
}
break;
case STRING:
((ArrayList<Byte>) data).clear();
for(int index = 0; index < numElements; ++index) {
((ArrayList<Byte>) data).add((byte) 0);
}
break;
}
}
@ -633,7 +639,7 @@ public class UAVObjectField {
numBytesPerElement = 1;
break;
case STRING:
data = new ArrayList<String>(this.numElements);
data = new ArrayList<Byte>(this.numElements);
numBytesPerElement = 1;
break;
default:
@ -650,15 +656,9 @@ public class UAVObjectField {
*/
protected Long bound (Object val) {
switch(type) {
case ENUM:
case STRING:
return 0L;
case FLOAT32:
return ((Number) val).longValue();
}
long num = ((Number) val).longValue();
long num = 0;
if (isNumeric())
num = ((Number) val).longValue();
switch(type) {
case INT8:
@ -703,6 +703,11 @@ public class UAVObjectField {
if(num > 255)
return (long) 255;
return num;
case FLOAT32:
return ((Number) val).longValue();
case ENUM:
case STRING:
return 0L;
}
return num;