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

Commit 079aaf12 authored by Zaiyue Xue's avatar Zaiyue Xue
Browse files

Fix b/243746796 Crash when mouse hangs over an empty battery chart

Bug: 243746796
Fix: 243746796
Test: manual
Change-Id: I3e595c96a55f1114b50ed5ed8e49e962cc90cbde
parent 0e5de165
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -595,6 +595,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick

    // Searches the corresponding trapezoid index from x location.
    private int getTrapezoidIndex(float x) {
        if (mTrapezoidSlots != null) {
            for (int index = 0; index < mTrapezoidSlots.length; index++) {
                final TrapezoidSlot slot = mTrapezoidSlots[index];
                if (x >= slot.mLeft - mTrapezoidHOffset
@@ -602,6 +603,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
                    return index;
                }
            }
        }
        return BatteryChartViewModel.SELECTED_INDEX_INVALID;
    }