Merge "Fix b/241885070: Unexpected texts moving when going back to battery usage page"
This commit is contained in:
committed by
Android (Google) Code Review
commit
8ebd4a5f8e
@@ -273,7 +273,7 @@ public class BatteryChartPreferenceControllerV2 extends AbstractPreferenceContro
|
||||
mDailyTimestampFullTexts = null;
|
||||
mDailyViewModel = null;
|
||||
mHourlyViewModels = null;
|
||||
addFooterPreferenceIfNeeded(false);
|
||||
refreshUi();
|
||||
return;
|
||||
}
|
||||
mDailyTimestampFullTexts = generateTimestampDayOfWeekTexts(
|
||||
@@ -336,14 +336,20 @@ public class BatteryChartPreferenceControllerV2 extends AbstractPreferenceContro
|
||||
|
||||
@VisibleForTesting
|
||||
boolean refreshUi() {
|
||||
if (mBatteryUsageMap == null || mDailyChartView == null || mHourlyChartView == null) {
|
||||
if (mDailyChartView == null || mHourlyChartView == null) {
|
||||
// Chart views are not initialized.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mDailyViewModel == null || mHourlyViewModels == null) {
|
||||
// Fail to get battery level data, show an empty hourly chart view.
|
||||
mDailyChartView.setVisibility(View.GONE);
|
||||
mHourlyChartView.setVisibility(View.VISIBLE);
|
||||
mHourlyChartView.setViewModel(null);
|
||||
addFooterPreferenceIfNeeded(false);
|
||||
return false;
|
||||
}
|
||||
if (mBatteryUsageMap == null) {
|
||||
// Battery usage data is not ready, wait for data ready to refresh UI.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -158,7 +158,6 @@ public class BatteryChartViewV2 extends AppCompatImageView implements View.OnCli
|
||||
} else {
|
||||
mTextPaint = null;
|
||||
}
|
||||
setVisibility(View.VISIBLE);
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user