Restore default vl
This commit is contained in:
parent
dffbd49153
commit
804bc025bb
1 changed files with 16 additions and 6 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue