From e4401ed22c0f65db5d4f1a1f0e1222b061e471af Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Thu, 18 Sep 2014 13:53:09 +1000 Subject: [PATCH] Don't show progress for every app being processed from index.xml. Rather, only show 25 progress events. I went with "25 events" rather than "every X apps" because then it will be nice for both large repos (e.g. F-Droid will update every ~50 apps) and small repos (something with 20 apps will update for every one, but not add much overhead). On my testing with an API 11 emulator here, it went from ~32s to process ~1100 apps to ~20s. When no progress events are sent, then it also takes ~20s, so this essentially is a 50% improvement for this part of the update process. --- CHANGELOG.md | 2 ++ src/org/fdroid/fdroid/RepoXMLHandler.java | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a50a9bba2..4e1f08fc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ * Initial support for root and system installers, allowing the client to install apks directly on its own +* Increased performance when updating from repository with many apps + * Switch to Appcompat from the Support library * Fix some crashes diff --git a/src/org/fdroid/fdroid/RepoXMLHandler.java b/src/org/fdroid/fdroid/RepoXMLHandler.java index f85a8eafc..607d3d7f6 100644 --- a/src/org/fdroid/fdroid/RepoXMLHandler.java +++ b/src/org/fdroid/fdroid/RepoXMLHandler.java @@ -279,14 +279,15 @@ public class RepoXMLHandler extends DefaultHandler { } else if (localName.equals("application") && curapp == null) { curapp = new App(); curapp.id = attributes.getValue("", "id"); + if (progressCounter % (totalAppCount / 25) == 0) { + Bundle data = new Bundle(1); + data.putString(RepoUpdater.PROGRESS_DATA_REPO_ADDRESS, repo.address); + progressListener.onProgress( + new ProgressListener.Event( + RepoUpdater.PROGRESS_TYPE_PROCESS_XML, + progressCounter, totalAppCount, data)); + } progressCounter ++; - Bundle data = new Bundle(1); - data.putString(RepoUpdater.PROGRESS_DATA_REPO_ADDRESS, repo.address); - progressListener.onProgress( - new ProgressListener.Event( - RepoUpdater.PROGRESS_TYPE_PROCESS_XML, - progressCounter, totalAppCount, data)); - } else if (localName.equals("package") && curapp != null && curapk == null) { curapk = new Apk(); curapk.id = curapp.id;