Merge "Cache summary text to avoid flickering" into tm-dev am: bd4b23ba0d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/18328550 Change-Id: I2ed88c37d72f206af245a0c62037289e3015ad43 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -31,9 +31,9 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll
|
||||
private static final IntentFilter INTENT_FILTER_LOCATION_MODE_CHANGED =
|
||||
new IntentFilter(LocationManager.MODE_CHANGED_ACTION);
|
||||
private final LocationManager mLocationManager;
|
||||
/** Total number of apps that has location permission. */
|
||||
private int mNumTotal = -1;
|
||||
private int mNumTotalLoading = 0;
|
||||
/** Summary text. */
|
||||
private static String sSummary = null;
|
||||
private BroadcastReceiver mReceiver;
|
||||
private Preference mPreference;
|
||||
private AtomicInteger loadingInProgress = new AtomicInteger(0);
|
||||
@@ -51,12 +51,11 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
if (mLocationManager.isLocationEnabled()) {
|
||||
if (mNumTotal == -1) {
|
||||
return mContext.getString(R.string.location_settings_loading_app_permission_stats);
|
||||
if (sSummary == null) {
|
||||
sSummary = mContext.getString(
|
||||
R.string.location_settings_loading_app_permission_stats);
|
||||
}
|
||||
return mContext.getResources().getQuantityString(
|
||||
R.plurals.location_settings_summary_location_on,
|
||||
mNumTotal, mNumTotal);
|
||||
return sSummary;
|
||||
} else {
|
||||
return mContext.getString(R.string.location_settings_summary_location_off);
|
||||
}
|
||||
@@ -64,7 +63,8 @@ public class TopLevelLocationPreferenceController extends BasePreferenceControll
|
||||
|
||||
@VisibleForTesting
|
||||
void setLocationAppCount(int numApps) {
|
||||
mNumTotal = numApps;
|
||||
sSummary = mContext.getResources().getQuantityString(
|
||||
R.plurals.location_settings_summary_location_on, numApps, numApps);
|
||||
refreshSummary(mPreference);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user