Restore default vl

This commit is contained in:
Victor Shcherb 2019-07-22 13:08:12 +02:00
parent dffbd49153
commit 804bc025bb

View file

@ -31,40 +31,50 @@ public class LiveUpdatesHelper {
public static final int DEFAULT_LAST_CHECK = -1;
private static <T> OsmandSettings.CommonPreference<T> checkPref(OsmandSettings.CommonPreference<T> p) {
if(p.isSet()) {
T vl = p.get();
p = p.makeGlobal();
p.set(vl);
} else {
p = p.makeGlobal();
}
return p;
}
public static OsmandSettings.CommonPreference<Boolean> preferenceForLocalIndex(
String fileName, OsmandSettings settings) {
final String settingId = fileName + LIVE_UPDATES_ON_POSTFIX;
return settings.registerBooleanPreference(settingId, false).makeGlobal();
return checkPref(settings.registerBooleanPreference(settingId, false));
}
public static OsmandSettings.CommonPreference<Boolean> preferenceLiveUpdatesOn(
String fileName, OsmandSettings settings) {
final String settingId = fileName + LIVE_UPDATES_ON_POSTFIX;
return settings.registerBooleanPreference(settingId, false).makeGlobal();
return checkPref(settings.registerBooleanPreference(settingId, false));
}
public static OsmandSettings.CommonPreference<Boolean> preferenceDownloadViaWiFi(
String fileName, OsmandSettings settings) {
final String settingId = fileName + DOWNLOAD_VIA_WIFI_POSTFIX;
return settings.registerBooleanPreference(settingId, false).makeGlobal();
return checkPref(settings.registerBooleanPreference(settingId, false));
}
public static OsmandSettings.CommonPreference<Integer> preferenceUpdateFrequency(
String fileName, OsmandSettings settings) {
final String settingId = fileName + UPDATE_TIMES_POSTFIX;
return settings.registerIntPreference(settingId, UpdateFrequency.HOURLY.ordinal()).makeGlobal();
return checkPref(settings.registerIntPreference(settingId, UpdateFrequency.HOURLY.ordinal()));
}
public static OsmandSettings.CommonPreference<Integer> preferenceTimeOfDayToUpdate(
String fileName, OsmandSettings settings) {
final String settingId = fileName + TIME_OF_DAY_TO_UPDATE_POSTFIX;
return settings.registerIntPreference(settingId, TimeOfDay.NIGHT.ordinal()).makeGlobal();
return checkPref(settings.registerIntPreference(settingId, TimeOfDay.NIGHT.ordinal()));
}
public static OsmandSettings.CommonPreference<Long> preferenceLastCheck(
String fileName, OsmandSettings settings) {
final String settingId = fileName + LAST_UPDATE_ATTEMPT_ON_POSTFIX;
return settings.registerLongPreference(settingId, DEFAULT_LAST_CHECK).makeGlobal();
return checkPref(settings.registerLongPreference(settingId, DEFAULT_LAST_CHECK));
}
public static String getNameToDisplay(String fileName, OsmandActionBarActivity activity) {