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

Commit fb04afb1 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

DockBatteryMeter: Avoid double detach when view is rebuilt

If the view is reconstructed for some reason (like applying a theme)
on a device without a dock battery, it'll try to detach and unregister
twice. The second unregister will case an NPE since the first one
killed the listener. Fixit.

Change-Id: Idcc0c7c87ef205ddc085a9e036fe630afd9d7012
parent 8427f34c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -127,6 +127,15 @@ public class DockBatteryMeterView extends BatteryMeterView {
        mTracker = new DockBatteryTracker();
    }

    @Override
    public void onDetachedFromWindow() {
        // We already unregistered the listener once when we decided
        // support was absent. Don't do it again.
        if (mSupported) {
            super.onDetachedFromWindow();
        }
    }

    @Override
    public void setMode(BatteryMeterMode mode) {
        super.setMode(mode);