Skip to content

Commit 00e363d

Browse files
author
Keisuke Kobayashi
committedJul 12, 2017
Fix exception on restore state
1 parent 8bf97e6 commit 00e363d

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed
 

‎library/src/main/java/io/github/kobakei/materialfabspeeddial/FabSpeedDial.java

+11-13
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,22 @@ public FabSpeedDial(@NonNull Context context, @Nullable AttributeSet attrs, @Att
107107
protected Parcelable onSaveInstanceState() {
108108
Parcelable parcelable = super.onSaveInstanceState();
109109
SavedState savedState = new SavedState(parcelable);
110-
savedState.isOpend = isOpened;
110+
savedState.isOpened = isOpened;
111111
return savedState;
112112
}
113113

114114
@Override
115115
protected void onRestoreInstanceState(Parcelable state) {
116-
if (!(state instanceof SavedState)) {
117-
super.onRestoreInstanceState(state);
118-
return;
119-
}
120-
121-
SavedState ss = (SavedState) state;
122-
super.onRestoreInstanceState(ss.getSuperState());
123-
124-
if (ss.isOpend) {
125-
openMenu();
116+
if (state instanceof SavedState) {
117+
SavedState ss = (SavedState) state;
118+
if (ss.isOpened) {
119+
openMenu();
120+
} else {
121+
closeMenu();
122+
}
123+
super.onRestoreInstanceState(ss.getSuperState());
126124
} else {
127-
closeMenu();
125+
super.onRestoreInstanceState(BaseSavedState.EMPTY_STATE);
128126
}
129127
}
130128

@@ -648,7 +646,7 @@ public boolean onDependentViewChanged(CoordinatorLayout parent, FabSpeedDial chi
648646

649647
private static class SavedState extends BaseSavedState {
650648

651-
boolean isOpend = false;
649+
boolean isOpened = false;
652650

653651
public SavedState(Parcelable source) {
654652
super(source);

0 commit comments

Comments
 (0)
Please sign in to comment.