1
1
package fr .free .nrw .commons .nearby ;
2
2
3
3
import android .content .Context ;
4
+ import android .os .Bundle ;
4
5
import android .os .Parcel ;
5
6
import android .os .Parcelable ;
6
7
import android .util .AttributeSet ;
@@ -64,12 +65,6 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
64
65
*/
65
66
private OnCheckedChangeListener clientListener ;
66
67
67
- /**
68
- * This flag is needed to avoid accidentally changing the current {@link #state} when
69
- * {@link #onRestoreInstanceState(Parcelable)} calls {@link #setChecked(boolean)}
70
- * evoking our {@link #privateListener} and therefore changing the real state.
71
- */
72
- private boolean restoring ;
73
68
74
69
public CheckBoxTriStates (Context context ) {
75
70
super (context );
@@ -91,7 +86,7 @@ public int getState() {
91
86
}
92
87
93
88
public void setState (int state ) {
94
- if (! this . restoring && this .state != state ) {
89
+ if (this .state != state ) {
95
90
this .state = state ;
96
91
97
92
if (this .clientListener != null ) {
@@ -118,27 +113,6 @@ public void setOnCheckedChangeListener(@Nullable OnCheckedChangeListener listene
118
113
super .setOnCheckedChangeListener (privateListener );
119
114
}
120
115
121
- @ Override
122
- public Parcelable onSaveInstanceState () {
123
- Parcelable superState = super .onSaveInstanceState ();
124
-
125
- SavedState ss = new SavedState (superState );
126
-
127
- ss .state = state ;
128
-
129
- return ss ;
130
- }
131
-
132
- @ Override
133
- public void onRestoreInstanceState (Parcelable state ) {
134
- this .restoring = true ; // indicates that the ui is restoring its state
135
- SavedState ss = (SavedState ) state ;
136
- super .onRestoreInstanceState (ss .getSuperState ());
137
- setState (ss .state );
138
- requestLayout ();
139
- this .restoring = false ;
140
- }
141
-
142
116
private void init () {
143
117
state = UNKNOWN ;
144
118
updateBtn ();
@@ -164,44 +138,4 @@ private void updateBtn() {
164
138
setButtonDrawable (btnDrawable );
165
139
166
140
}
167
-
168
- static class SavedState extends BaseSavedState {
169
- int state ;
170
-
171
- SavedState (Parcelable superState ) {
172
- super (superState );
173
- }
174
-
175
- private SavedState (Parcel in ) {
176
- super (in );
177
- state = in .readInt ();
178
- }
179
-
180
- @ Override
181
- public void writeToParcel (Parcel out , int flags ) {
182
- super .writeToParcel (out , flags );
183
- out .writeValue (state );
184
- }
185
-
186
- @ Override
187
- public String toString () {
188
- return "CheckboxTriState.SavedState{"
189
- + Integer .toHexString (System .identityHashCode (this ))
190
- + " state=" + state + "}" ;
191
- }
192
-
193
- @ SuppressWarnings ("hiding" )
194
- public static final Parcelable .Creator <SavedState > CREATOR =
195
- new Parcelable .Creator <SavedState >() {
196
- @ Override
197
- public SavedState createFromParcel (Parcel in ) {
198
- return new SavedState (in );
199
- }
200
-
201
- @ Override
202
- public SavedState [] newArray (int size ) {
203
- return new SavedState [size ];
204
- }
205
- };
206
- }
207
141
}
0 commit comments