ruffy: take over Menu changes (robustness, presumably), from 46e92833.

This commit is contained in:
Johannes Mockenhaupt 2017-10-18 23:23:26 +02:00
parent 51aceadfb1
commit d9235cf54b
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -2,6 +2,7 @@ package org.monkey.d.ruffy.ruffy.driver.display;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; 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.BolusType;
import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuBlink; import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuBlink;
@ -34,6 +35,7 @@ public class Menu implements Parcelable {
String clas = in.readString(); String clas = in.readString();
String value = in.readString(); String value = in.readString();
if(attr!=null && clas!=null && value!=null) {
MenuAttribute a = MenuAttribute.valueOf(attr); MenuAttribute a = MenuAttribute.valueOf(attr);
Object o = null; Object o = null;
if (Integer.class.toString().equals(clas)) { if (Integer.class.toString().equals(clas)) {
@ -52,16 +54,24 @@ public class Menu implements Parcelable {
o = BolusType.valueOf(value); o = BolusType.valueOf(value);
} else if (String.class.toString().equals(clas)) { } else if (String.class.toString().equals(clas)) {
o = new String(value); o = new String(value);
} else {
Log.e("MENU","unknown class: "+clas);
} }
if (o != null) { if (o != null) {
attributes.put(a, o); attributes.put(a, o);
} else { } 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) }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 try
{ {
dest.writeString(a.toString());
Object o = attributes.get(a);
dest.writeString(o.getClass().toString()); String atr = a.toString();
dest.writeString(o.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) }catch(Exception e)
{ {
// Log.v("MenuOut","error in write",e); Log.v("MenuOut","error in write",e);
} }
} }
} }