Conversation
…es not accept List but accept ArrayList
|
Looks great !! A few notes :
@SaveOnActivityDestroy
Boolean myBooleanObject;
// ...
if (myBooleanObject!= null) {
bundle.putBoolean("myBooleanObject", myBooleanObject);
}
// ...
myBooleanObject = savedInstanceState.getBoolean("myBooleanObject");
So basically, if myBooleanObject is |
|
The loading code could in fact be : if (savedInstanceState.containsKey("myBooleanObject")) {
myBooleanObject = savedInstanceState.getBoolean("myBooleanObject");
}Another option, maybe even more appropriate, would be to use @SaveOnActivityDestroy
Boolean myBooleanObject;
// ...
bundle.putSerializable("myBooleanObject", myBooleanObject);
// ...
myBooleanObject = (Boolean) savedInstanceState.getSerializable("myBooleanObject");I think the latter is safer, because it handle the case where you have an init value : @SaveOnActivityDestroy
Boolean myBooleanObject = true;If at some point you do
|
|
A few more notes : GenericsGenerics don't work yet. Lists work because they are part of the "trivial list", but look at this : @SaveOnActivityDestroy
MyGenericSerializableBean<MySerializableBean> myGenericSerializableBean;It generates the following compile error : API Level 8In the processor, the following code was commented : // Added on API level 8
// methodSuffixNameByTypeName.put("java.lang.CharSequence[]", "CharSequenceArray");
// methodSuffixNameByTypeName.put("java.util.ArrayList<java.lang.CharSequence>", "CharSequenceArrayList");I removed it, we shouldn't leave that kind of commented dead code somewhere. However, that doesn't solve the issue you were talking about. I think we can decide to not support such types, and resort to saving them as Serializable instead. |
|
@matboniface What's your opinion regarding generics ? |
77 save instance state. Fixes #77
This is a first implementation of @SaveOnActivityDestroy annotation explained on issue #77.