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:
@@ -71,6 +71,7 @@ public final class ConvertUtils {
|
||||
|
||||
private static String sZoneId;
|
||||
private static SimpleDateFormat sSimpleDateFormat;
|
||||
private static SimpleDateFormat sSimpleDateFormatForHour;
|
||||
|
||||
private ConvertUtils() {}
|
||||
|
||||
@@ -139,10 +140,27 @@ public final class ConvertUtils {
|
||||
sZoneId = currentZoneId;
|
||||
sSimpleDateFormat =
|
||||
new SimpleDateFormat("MMM dd,yyyy HH:mm:ss", Locale.ENGLISH);
|
||||
sSimpleDateFormatForHour = null;
|
||||
}
|
||||
return sSimpleDateFormat.format(new Date(timestamp));
|
||||
}
|
||||
|
||||
/** Converts UTC timestamp to local time hour data. */
|
||||
public static int utcToLocalTimeHour(long timestamp) {
|
||||
final String currentZoneId = TimeZone.getDefault().getID();
|
||||
if (!currentZoneId.equals(sZoneId) || sSimpleDateFormatForHour == null) {
|
||||
sZoneId = currentZoneId;
|
||||
sSimpleDateFormat = null;
|
||||
sSimpleDateFormatForHour = new SimpleDateFormat("HH", Locale.ENGLISH);
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(
|
||||
sSimpleDateFormatForHour.format(new Date(timestamp)));
|
||||
} catch (NumberFormatException e) {
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
/** Gets indexed battery usage data for each corresponding time slot. */
|
||||
public static Map<Integer, List<BatteryDiffEntry>> getIndexedUsageMap(
|
||||
final Context context,
|
||||
|
Reference in New Issue
Block a user