Fix b/243746796 Crash when mouse hangs over an empty battery chart
Bug: 243746796 Fix: 243746796 Test: manual Change-Id: I3e595c96a55f1114b50ed5ed8e49e962cc90cbde
This commit is contained in:
@@ -595,11 +595,13 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
||||
|
||||
// Searches the corresponding trapezoid index from x location.
|
||||
private int getTrapezoidIndex(float x) {
|
||||
for (int index = 0; index < mTrapezoidSlots.length; index++) {
|
||||
final TrapezoidSlot slot = mTrapezoidSlots[index];
|
||||
if (x >= slot.mLeft - mTrapezoidHOffset
|
||||
&& x <= slot.mRight + mTrapezoidHOffset) {
|
||||
return index;
|
||||
if (mTrapezoidSlots != null) {
|
||||
for (int index = 0; index < mTrapezoidSlots.length; index++) {
|
||||
final TrapezoidSlot slot = mTrapezoidSlots[index];
|
||||
if (x >= slot.mLeft - mTrapezoidHOffset
|
||||
&& x <= slot.mRight + mTrapezoidHOffset) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
return BatteryChartViewModel.SELECTED_INDEX_INVALID;
|
||||
|
Reference in New Issue
Block a user