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;
|
mDailyTimestampFullTexts = null;
|
||||||
mDailyViewModel = null;
|
mDailyViewModel = null;
|
||||||
mHourlyViewModels = null;
|
mHourlyViewModels = null;
|
||||||
addFooterPreferenceIfNeeded(false);
|
refreshUi();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mDailyTimestampFullTexts = generateTimestampDayOfWeekTexts(
|
mDailyTimestampFullTexts = generateTimestampDayOfWeekTexts(
|
||||||
@@ -336,14 +336,20 @@ public class BatteryChartPreferenceControllerV2 extends AbstractPreferenceContro
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean refreshUi() {
|
boolean refreshUi() {
|
||||||
if (mBatteryUsageMap == null || mDailyChartView == null || mHourlyChartView == null) {
|
if (mDailyChartView == null || mHourlyChartView == null) {
|
||||||
|
// Chart views are not initialized.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDailyViewModel == null || mHourlyViewModels == null) {
|
if (mDailyViewModel == null || mHourlyViewModels == null) {
|
||||||
// Fail to get battery level data, show an empty hourly chart view.
|
// Fail to get battery level data, show an empty hourly chart view.
|
||||||
mDailyChartView.setVisibility(View.GONE);
|
mDailyChartView.setVisibility(View.GONE);
|
||||||
|
mHourlyChartView.setVisibility(View.VISIBLE);
|
||||||
mHourlyChartView.setViewModel(null);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,6 @@ public class BatteryChartViewV2 extends AppCompatImageView implements View.OnCli
|
|||||||
} else {
|
} else {
|
||||||
mTextPaint = null;
|
mTextPaint = null;
|
||||||
}
|
}
|
||||||
setVisibility(View.VISIBLE);
|
|
||||||
requestLayout();
|
requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user