Avoid add preferenc again if it already in the PreferenceGroup

Bug: 177406865
Bug: 185187729
Test: make SettingsRoboTests
Test: make SettingsGoogleRoboTests
Change-Id: I69f5033c0a07d846c340b9871e69a2cdbe0bb2aa
This commit is contained in:
ykhung
2021-04-23 01:07:09 +08:00
parent 09f6086bea
commit 5c23d65901
5 changed files with 76 additions and 27 deletions

View File

@@ -97,8 +97,18 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
public void setLevels(int[] levels) {
// We should provide trapezoid count + 1 data to draw all trapezoids.
mLevels = levels.length == mTrapezoidCount + 1 ? levels : null;
setClickable(mLevels != null);
setClickable(false);
invalidate();
if (mLevels == null) {
return;
}
// Sets the chart is clickable if there is at least one valid item in it.
for (int index = 0; index < mLevels.length; index++) {
if (mLevels[index] != 0) {
setClickable(true);
break;
}
}
}
/** Sets the selected group index to draw highlight effect. */