Only create compatibility checker once per repo.

Looks like a non-trivial amount of work is done in the constructor
interrogating the features of the current device. This only needs
to be done once.
This commit is contained in:
Peter Serwylo 2015-12-13 10:28:03 +11:00
parent 9727dc505c
commit c24cd89028

View File

@ -62,9 +62,13 @@ public class RepoPersister {
@NonNull @NonNull
private final Map<String, List<Apk>> apksToSave = new HashMap<>(); private final Map<String, List<Apk>> apksToSave = new HashMap<>();
@NonNull
private final CompatibilityChecker checker;
public RepoPersister(@NonNull Context context, @NonNull Repo repo) { public RepoPersister(@NonNull Context context, @NonNull Repo repo) {
this.repo = repo; this.repo = repo;
this.context = context; this.context = context;
checker = new CompatibilityChecker(context);
} }
public void saveToDb(App app, List<Apk> packages) throws RepoUpdater.UpdateException { public void saveToDb(App app, List<Apk> packages) throws RepoUpdater.UpdateException {
@ -281,7 +285,6 @@ public class RepoPersister {
* in order to see if, and why an apk is not compatible. * in order to see if, and why an apk is not compatible.
*/ */
private void calcApkCompatibilityFlags(List<Apk> apks) { private void calcApkCompatibilityFlags(List<Apk> apks) {
final CompatibilityChecker checker = new CompatibilityChecker(context);
for (final Apk apk : apks) { for (final Apk apk : apks) {
final List<String> reasons = checker.getIncompatibleReasons(apk); final List<String> reasons = checker.getIncompatibleReasons(apk);
if (reasons.size() > 0) { if (reasons.size() > 0) {