ruffy: take over Menu changes (robustness, presumably), from 46e92833.
This commit is contained in:
parent
51aceadfb1
commit
d9235cf54b
|
@ -2,6 +2,7 @@ package org.monkey.d.ruffy.ruffy.driver.display;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
import org.monkey.d.ruffy.ruffy.driver.display.menu.BolusType;
|
||||
import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuBlink;
|
||||
|
@ -34,6 +35,7 @@ public class Menu implements Parcelable {
|
|||
String clas = in.readString();
|
||||
String value = in.readString();
|
||||
|
||||
if(attr!=null && clas!=null && value!=null) {
|
||||
MenuAttribute a = MenuAttribute.valueOf(attr);
|
||||
Object o = null;
|
||||
if (Integer.class.toString().equals(clas)) {
|
||||
|
@ -52,16 +54,24 @@ public class Menu implements Parcelable {
|
|||
o = BolusType.valueOf(value);
|
||||
} else if (String.class.toString().equals(clas)) {
|
||||
o = new String(value);
|
||||
} else {
|
||||
Log.e("MENU","unknown class: "+clas);
|
||||
}
|
||||
|
||||
|
||||
if (o != null) {
|
||||
attributes.put(a, o);
|
||||
} else {
|
||||
// Log.e("MenuIn", "failed to parse: " + attr + " / " + clas + " / " + value);
|
||||
Log.e("MenuIn", "failed to parse: " + attr + " / " + clas + " / " + value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.e("MenuIn", "failed to parse: " + attr + " / " + clas + " / " + value);
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
// Log.e("MenuIn","Exception in read",e);
|
||||
Log.e("MenuIn","Exception in read",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -98,14 +108,23 @@ public class Menu implements Parcelable {
|
|||
{
|
||||
try
|
||||
{
|
||||
dest.writeString(a.toString());
|
||||
Object o = attributes.get(a);
|
||||
|
||||
dest.writeString(o.getClass().toString());
|
||||
dest.writeString(o.toString());
|
||||
String atr = a.toString();
|
||||
Object o = attributes.get(a);
|
||||
String clas = o.getClass().toString();
|
||||
String v = o.toString();
|
||||
if(atr != null && o != null && v != null) {
|
||||
dest.writeString(atr);
|
||||
dest.writeString(clas);
|
||||
dest.writeString(v);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.e("Menu","null in write :/");
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
// Log.v("MenuOut","error in write",e);
|
||||
Log.v("MenuOut","error in write",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue