if (savedInstanceState != null) {
keep |= savedInstanceState.getBoolean("keep", true);
focused = savedInstanceState.getInt("focused-item", 0);
- element = FocusedElement.valueOf(savedInstanceState.getString("focused-element"));
+ final String focusedElementString = savedInstanceState.getString("focused-element");
+ if (focusedElementString != null)
+ element = FocusedElement.valueOf(focusedElementString);
}
if (!keep) {
final int focusedItem = focusInfo.position;
if (focusedItem >= 0)
outState.putInt("focused-item", focusedItem);
- outState.putString("focused-element", focusInfo.element.toString());
+ if (focusInfo.element != null)
+ outState.putString("focused-element", focusInfo.element.toString());
}
}
noteFocusChanged(fi.position - 1, fi.element);
setItems(newList);
}
- void noteFocusChanged(int position, FocusedElement element) {
+ void noteFocusChanged(int position, @Nullable FocusedElement element) {
FocusInfo present = focusInfo.getValue();
if (present == null || present.position != position || present.element != element)
focusInfo.setValue(new FocusInfo(position, element));
public static class FocusInfo {
int position;
FocusedElement element;
- public FocusInfo(int position, FocusedElement element) {
+ public FocusInfo(int position, @Nullable FocusedElement element) {
this.position = position;
this.element = element;
}