Avoid drawing the invalid levels in the chart view

Bug: 183921876
Test: make SettingsRoboTests
Test: make SettingsGoogleRoboTests
Change-Id: Id540f35044beabe4d56ab5ce3af63271ac356f49
This commit is contained in:
ykhung
2021-04-10 18:49:03 +08:00
committed by YUKAI HUNG
parent 9b226a4ff0
commit 40319d9d6f

View File

@@ -227,6 +227,10 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
// Draws all trapezoid shapes into the canvas.
final Path trapezoidPath = new Path();
for (int index = 0; index < mTrapezoidCount; index++) {
// Not draws the trapezoid for corner or not initialization cases.
if (mLevels[index] == 0 || mLevels[index + 1] == 0) {
continue;
}
// Configures the trapezoid paint color.
mTrapezoidPaint.setColor(
mSelectedIndex == index || mSelectedIndex == SELECTED_INDEX_ALL