Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5f53a59 authored by Evan Laird's avatar Evan Laird Committed by Gerrit Code Review
Browse files

Merge "revent NFE in SystemUI when parsing invalid int (2)"

parents 1276a178 a2c86e8a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -127,12 +127,12 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
    @Override
    public void onTuningChanged(String key, String newValue) {
        if (ALLOW_FANCY_ANIMATION.equals(key)) {
            mAllowFancy = newValue == null || Integer.parseInt(newValue) != 0;
            mAllowFancy = TunerService.parseIntegerSwitch(newValue, true);
            if (!mAllowFancy) {
                clearAnimationState();
            }
        } else if (MOVE_FULL_ROWS.equals(key)) {
            mFullRows = newValue == null || Integer.parseInt(newValue) != 0;
            mFullRows = TunerService.parseIntegerSwitch(newValue, true);
        } else if (QuickQSPanel.NUM_QUICK_TILES.equals(key)) {
            mNumQuickTiles = mQuickQsPanel.getNumQuickTiles(mQs.getContext());
            clearAnimationState();
+1 −1
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
    }

    private void updateViewVisibilityForTuningValue(View view, @Nullable String newValue) {
        view.setVisibility(newValue == null || Integer.parseInt(newValue) != 0 ? VISIBLE : GONE);
        view.setVisibility(TunerService.parseIntegerSwitch(newValue, true) ? VISIBLE : GONE);
    }

    public void openDetails(String subPanel) {
+1 −1
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
    @Override
    public void onTuningChanged(String key, String newValue) {
        if (CLOCK_SECONDS.equals(key)) {
            mShowSeconds = newValue != null && Integer.parseInt(newValue) != 0;
            mShowSeconds = TunerService.parseIntegerSwitch(newValue, false);
            updateShowSeconds();
        } else {
            setClockVisibleByUser(!StatusBarIconController.getIconBlacklist(newValue)
+8 −0
Original line number Diff line number Diff line
@@ -109,4 +109,12 @@ public abstract class TunerService {
        });
        dialog.show();
    }

    public static boolean parseIntegerSwitch(String value, boolean defaultValue) {
        try {
            return value != null ? Integer.parseInt(value) != 0 : defaultValue;
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public class TunerSwitch extends SwitchPreference implements Tunable {

    @Override
    public void onTuningChanged(String key, String newValue) {
        setChecked(newValue != null ? Integer.parseInt(newValue) != 0 : mDefault);
        setChecked(TunerService.parseIntegerSwitch(newValue, mDefault));
    }

    @Override
Loading