mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
AndroidGCS: Suppress some warnings related to not implementing the STRING uavfield type properly.
This commit is contained in:
parent
f01edc5d72
commit
120f9298b4
@ -22,22 +22,22 @@ public class ObjectEditView extends GridLayout {
|
|||||||
public List<View> fields;
|
public List<View> fields;
|
||||||
|
|
||||||
public ObjectEditView(Context context) {
|
public ObjectEditView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
initObjectEditView();
|
initObjectEditView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectEditView(Context context, AttributeSet ats, int defaultStyle) {
|
public ObjectEditView(Context context, AttributeSet ats, int defaultStyle) {
|
||||||
super(context, ats);
|
super(context, ats);
|
||||||
initObjectEditView();
|
initObjectEditView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectEditView(Context context, AttributeSet ats) {
|
public ObjectEditView(Context context, AttributeSet ats) {
|
||||||
super(context, ats);
|
super(context, ats);
|
||||||
initObjectEditView();
|
initObjectEditView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initObjectEditView() {
|
public void initObjectEditView() {
|
||||||
// Set orientation of layout to vertical
|
// Set orientation of layout to vertical
|
||||||
setOrientation(LinearLayout.VERTICAL);
|
setOrientation(LinearLayout.VERTICAL);
|
||||||
setColumnCount(2);
|
setColumnCount(2);
|
||||||
fields = new ArrayList<View>();
|
fields = new ArrayList<View>();
|
||||||
@ -51,11 +51,11 @@ public class ObjectEditView extends GridLayout {
|
|||||||
for (int i = 0; i < field.getNumElements(); i++)
|
for (int i = 0; i < field.getNumElements(); i++)
|
||||||
addRow(getContext(), field, i);
|
addRow(getContext(), field, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addRow(Context context, UAVObjectField field, int idx) {
|
public void addRow(Context context, UAVObjectField field, int idx) {
|
||||||
int row = getRowCount();
|
int row = getRowCount();
|
||||||
|
|
||||||
TextView fieldName = new TextView(context);
|
TextView fieldName = new TextView(context);
|
||||||
if(field.getNumElements() == 1) {
|
if(field.getNumElements() == 1) {
|
||||||
fieldName.setText(field.getName());
|
fieldName.setText(field.getName());
|
||||||
@ -65,7 +65,7 @@ public class ObjectEditView extends GridLayout {
|
|||||||
addView(fieldName, new GridLayout.LayoutParams(spec(row), spec(0)));
|
addView(fieldName, new GridLayout.LayoutParams(spec(row), spec(0)));
|
||||||
|
|
||||||
View fieldValue = null;
|
View fieldValue = null;
|
||||||
switch(field.getType())
|
switch(field.getType())
|
||||||
{
|
{
|
||||||
case FLOAT32:
|
case FLOAT32:
|
||||||
fieldValue = new EditText(context);
|
fieldValue = new EditText(context);
|
||||||
@ -93,8 +93,16 @@ public class ObjectEditView extends GridLayout {
|
|||||||
((Spinner) fieldValue).setAdapter(adapter);
|
((Spinner) fieldValue).setAdapter(adapter);
|
||||||
((Spinner) fieldValue).setSelection((int) field.getDouble(idx));
|
((Spinner) fieldValue).setSelection((int) field.getDouble(idx));
|
||||||
break;
|
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)));
|
addView(fieldValue, new GridLayout.LayoutParams(spec(row), spec(1)));
|
||||||
fields.add(fieldValue);
|
fields.add(fieldValue);
|
||||||
}
|
}
|
||||||
|
@ -578,6 +578,12 @@ public class UAVObjectField {
|
|||||||
((ArrayList<Byte>) data).add((byte) 0);
|
((ArrayList<Byte>) data).add((byte) 0);
|
||||||
}
|
}
|
||||||
break;
|
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;
|
numBytesPerElement = 1;
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
data = new ArrayList<String>(this.numElements);
|
data = new ArrayList<Byte>(this.numElements);
|
||||||
numBytesPerElement = 1;
|
numBytesPerElement = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -650,15 +656,9 @@ public class UAVObjectField {
|
|||||||
*/
|
*/
|
||||||
protected Long bound (Object val) {
|
protected Long bound (Object val) {
|
||||||
|
|
||||||
switch(type) {
|
long num = 0;
|
||||||
case ENUM:
|
if (isNumeric())
|
||||||
case STRING:
|
num = ((Number) val).longValue();
|
||||||
return 0L;
|
|
||||||
case FLOAT32:
|
|
||||||
return ((Number) val).longValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
long num = ((Number) val).longValue();
|
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case INT8:
|
case INT8:
|
||||||
@ -703,6 +703,11 @@ public class UAVObjectField {
|
|||||||
if(num > 255)
|
if(num > 255)
|
||||||
return (long) 255;
|
return (long) 255;
|
||||||
return num;
|
return num;
|
||||||
|
case FLOAT32:
|
||||||
|
return ((Number) val).longValue();
|
||||||
|
case ENUM:
|
||||||
|
case STRING:
|
||||||
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user