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

This commit is contained in:
TreeHugger Robot
2022-08-25 16:19:14 +00:00
committed by Android (Google) Code Review

View File

@@ -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;
}