From e44ca193dd0adcbc5e240410aec4c681f5053dae Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 19 Jul 2018 11:57:37 +0200 Subject: [PATCH] save result of Preferences.get() to speed up start up times The initial start time is getting pretty slow, so hopefully this will save a little bit. It also makes it consistent with other places in the code, like UpdateService. --- .../java/org/fdroid/fdroid/FDroidApp.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java index 19c097646..5b01a816d 100644 --- a/app/src/main/java/org/fdroid/fdroid/FDroidApp.java +++ b/app/src/main/java/org/fdroid/fdroid/FDroidApp.java @@ -349,8 +349,9 @@ public class FDroidApp extends Application { } Preferences.setup(this); Languages.setLanguage(this); + Preferences preferences = Preferences.get(); - if (Preferences.get().promptToSendCrashReports()) { + if (preferences.promptToSendCrashReports()) { ACRA.init(this); if (isAcraProcess() || HidingManager.isHidden(this)) { return; @@ -359,16 +360,15 @@ public class FDroidApp extends Application { PRNGFixes.apply(); - curTheme = Preferences.get().getTheme(); - Preferences.get().configureProxy(); + curTheme = preferences.getTheme(); + preferences.configureProxy(); // bug specific to exactly 5.0 makes it only work with the old index // which includes an ugly, hacky workaround // https://gitlab.com/fdroid/fdroidclient/issues/1014 if (Build.VERSION.SDK_INT == 21) { - Preferences p = Preferences.get(); - p.setExpertMode(true); - p.setForceOldIndex(true); + preferences.setExpertMode(true); + preferences.setForceOldIndex(true); } InstalledAppProviderService.compareToPackageManager(this); @@ -376,7 +376,7 @@ public class FDroidApp extends Application { // If the user changes the preference to do with filtering rooted apps, // it is easier to just notify a change in the app provider, // so that the newly updated list will correctly filter relevant apps. - Preferences.get().registerAppsRequiringRootChangeListener(new Preferences.ChangeListener() { + preferences.registerAppsRequiringRootChangeListener(new Preferences.ChangeListener() { @Override public void onPreferenceChange() { getContentResolver().notifyChange(AppProvider.getContentUri(), null); @@ -386,14 +386,14 @@ public class FDroidApp extends Application { // If the user changes the preference to do with filtering anti-feature apps, // it is easier to just notify a change in the app provider, // so that the newly updated list will correctly filter relevant apps. - Preferences.get().registerAppsRequiringAntiFeaturesChangeListener(new Preferences.ChangeListener() { + preferences.registerAppsRequiringAntiFeaturesChangeListener(new Preferences.ChangeListener() { @Override public void onPreferenceChange() { getContentResolver().notifyChange(AppProvider.getContentUri(), null); } }); - Preferences.get().registerUnstableUpdatesChangeListener(new Preferences.ChangeListener() { + preferences.registerUnstableUpdatesChangeListener(new Preferences.ChangeListener() { @Override public void onPreferenceChange() { AppProvider.Helper.calcSuggestedApks(FDroidApp.this); @@ -457,16 +457,16 @@ public class FDroidApp extends Application { FDroidApp.initWifiSettings(); WifiStateChangeService.start(this, null); // if the HTTPS pref changes, then update all affected things - Preferences.get().registerLocalRepoHttpsListeners(new ChangeListener() { + preferences.registerLocalRepoHttpsListeners(new ChangeListener() { @Override public void onPreferenceChange() { WifiStateChangeService.start(getApplicationContext(), null); } }); - configureTor(Preferences.get().isTorEnabled()); + configureTor(preferences.isTorEnabled()); - if (Preferences.get().isKeepingInstallHistory()) { + if (preferences.isKeepingInstallHistory()) { InstallHistoryService.register(this); } @@ -492,7 +492,7 @@ public class FDroidApp extends Application { atStartTime.edit().putInt("build-version", Build.VERSION.SDK_INT).apply(); final String queryStringKey = "http-downloader-query-string"; - if (Preferences.get().sendVersionAndUUIDToServers()) { + if (preferences.sendVersionAndUUIDToServers()) { HttpDownloader.queryString = atStartTime.getString(queryStringKey, null); if (HttpDownloader.queryString == null) { UUID uuid = UUID.randomUUID();