Precalculate the preferred metadata, rather than always at runtime

The  query which dynamically figured out the preferred metadata based on
repo priority ended up being quite slow (although it did work). On lower
end devices, it has the potential to make F-Droid quite sluggish. By
optimistically precalculating the preferred metadata where possible, we
don't need to ask the question during the usual usage of F-Droid, only
when:
 * Repo priorities are changed (there is not currently a UI for this, but
  there are tests)
 * Repos are enabled/disabled
 * Repo updates are performed
This commit is contained in:
Peter Serwylo
2016-09-26 18:32:12 +10:00
parent 01b8f7f4bf
commit ab02058ece
5 changed files with 90 additions and 11 deletions

View File

@@ -371,6 +371,9 @@ public class AppProviderTest extends FDroidProviderTest {
Uri uri = AppProvider.getContentUri();
contentResolver.insert(uri, values);
AppProvider.Helper.recalculatePreferredMetadata(context);
return AppProvider.Helper.findSpecificApp(context.getContentResolver(), id, 1, Cols.ALL);
}
}