2020import android .os .Parcel ;
2121import android .os .Parcelable ;
2222
23- import java .lang .UnsupportedOperationException ;
24- import java .lang .NullPointerException ;
2523import java .math .BigDecimal ;
2624import java .math .RoundingMode ;
2725import java .text .NumberFormat ;
@@ -291,18 +289,18 @@ public boolean isOrderOfOperationsApplied() {
291289 private CalcSettings (Parcel in ) {
292290 Bundle bundle = in .readBundle (getClass ().getClassLoader ());
293291 if (bundle != null ) {
294-
295292 requestCode = bundle .getInt ("requestCode" );
296293
297- //noinspection ConstantConditions
298294 if (bundle .containsKey ("nbFormat" )) {
299295 try {
300- nbFormat = (NumberFormat ) bundle .getSerializable ("nbFormat" );
296+ NumberFormat fmt = (NumberFormat ) bundle .getSerializable ("nbFormat" );
297+ if (fmt != null ) nbFormat = fmt ;
301298 } catch (NullPointerException npe ) {
302299 // Catch NPE exception on some Android 9 devices
303300 // see https://stackoverflow.com/q/53541154/8941877
304301 }
305302 }
303+
306304 //noinspection ConstantConditions
307305 numpadLayout = (CalcNumpadLayout ) bundle .getSerializable ("numpadLayout" );
308306 isExpressionShown = bundle .getBoolean ("isExpressionShown" );
@@ -311,12 +309,15 @@ private CalcSettings(Parcel in) {
311309 isSignBtnShown = bundle .getBoolean ("isSignBtnShown" );
312310 shouldEvaluateOnOperation = bundle .getBoolean ("shouldEvaluateOnOperation" );
313311
314- if (bundle .containsKey ("initialValue" ))
312+ if (bundle .containsKey ("initialValue" )) {
315313 initialValue = (BigDecimal ) bundle .getSerializable ("initialValue" );
316- if (bundle .containsKey ("minValue" ))
314+ }
315+ if (bundle .containsKey ("minValue" )) {
317316 minValue = (BigDecimal ) bundle .getSerializable ("minValue" );
318- if (bundle .containsKey ("maxValue" ))
317+ }
318+ if (bundle .containsKey ("maxValue" )) {
319319 maxValue = (BigDecimal ) bundle .getSerializable ("maxValue" );
320+ }
320321 isOrderOfOperationsApplied = bundle .getBoolean ("isOrderOfOperationsApplied" );
321322 }
322323 }
@@ -326,9 +327,7 @@ public void writeToParcel(@NonNull Parcel out, int flags) {
326327 Bundle bundle = new Bundle ();
327328
328329 bundle .putInt ("requestCode" , requestCode );
329- if (nbFormat != null ){
330- bundle .putSerializable ("nbFormat" , nbFormat );
331- }
330+ bundle .putSerializable ("nbFormat" , nbFormat );
332331 bundle .putSerializable ("numpadLayout" , numpadLayout );
333332 bundle .putBoolean ("isExpressionShown" , isExpressionShown );
334333 bundle .putBoolean ("isZeroShownWhenNoValue" , isZeroShownWhenNoValue );
@@ -341,9 +340,9 @@ public void writeToParcel(@NonNull Parcel out, int flags) {
341340 if (maxValue != null ) bundle .putSerializable ("maxValue" , maxValue );
342341 bundle .putBoolean ("isOrderOfOperationsApplied" , isOrderOfOperationsApplied );
343342
344- try {
343+ try {
345344 out .writeBundle (bundle );
346- } catch (UnsupportedOperationException uoe ){
345+ } catch (UnsupportedOperationException uoe ) {
347346 // Workaround for issue https://issuetracker.google.com/issues/37043137
348347 }
349348 }
0 commit comments