From 40f4482bd6085035b181aeb213ed53928f040b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 17 Sep 2013 20:54:21 +0200 Subject: [PATCH] Filtering bools are now done once per refresh --- src/org/fdroid/fdroid/DB.java | 4 ---- src/org/fdroid/fdroid/FDroid.java | 1 + src/org/fdroid/fdroid/FDroidApp.java | 12 +++++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 8ccb49d24..c53f30dc1 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -53,12 +53,10 @@ public class DB { private static Semaphore dbSync = new Semaphore(1, true); static DB dbInstance = null; - private static Context activityContext = null; // Initialise the database. Called once when the application starts up. static void initDB(Context ctx) { dbInstance = new DB(ctx); - activityContext = ctx; } // Get access to the database. Must be called before any database activity, @@ -758,7 +756,6 @@ public class DB { } Map apps = new HashMap(); - AppFilter appFilter = new AppFilter(activityContext); Cursor c = null; long startTime = System.currentTimeMillis(); try { @@ -791,7 +788,6 @@ public class DB { .parse(sLastUpdated); app.compatible = c.getInt(12) == 1; app.ignoreUpdates = c.getInt(13) == 1; - app.filtered = appFilter.filter(app); app.hasUpdates = false; if (getinstalledinfo && systemApks.containsKey(app.id)) { diff --git a/src/org/fdroid/fdroid/FDroid.java b/src/org/fdroid/fdroid/FDroid.java index 8e333cf93..35eb5478c 100644 --- a/src/org/fdroid/fdroid/FDroid.java +++ b/src/org/fdroid/fdroid/FDroid.java @@ -236,6 +236,7 @@ public class FDroid extends FragmentActivity { } break; case REQUEST_PREFS: + ((FDroidApp) getApplication()).filterApps(); // The automatic update settings may have changed, so reschedule (or // unschedule) the service accordingly. It's cheap, so no need to // check if the particular setting has actually been changed. diff --git a/src/org/fdroid/fdroid/FDroidApp.java b/src/org/fdroid/fdroid/FDroidApp.java index 27aac3edd..1709ff66f 100644 --- a/src/org/fdroid/fdroid/FDroidApp.java +++ b/src/org/fdroid/fdroid/FDroidApp.java @@ -66,12 +66,14 @@ public class FDroidApp extends Application { apps = null; invalidApps = new ArrayList(); - Context ctx = getApplicationContext(); + ctx = getApplicationContext(); DB.initDB(ctx); UpdateService.schedule(ctx); } + Context ctx; + // Global list of all known applications. private List apps; @@ -137,7 +139,15 @@ public class FDroidApp extends Application { } if (apps == null) return new ArrayList(); + filterApps(); return apps; } + public void filterApps() { + AppFilter appFilter = new AppFilter(ctx); + for (DB.App app : apps) { + app.filtered = appFilter.filter(app); + } + } + }