Replace some lists with counters

These objects/strings were probably useful at some point. They no longer
are.
This commit is contained in:
Daniel Martí 2015-12-08 15:24:51 +01:00
parent 637d3dddc4
commit 2067f15b27

View File

@ -351,9 +351,9 @@ public class UpdateService extends IntentService implements ProgressListener {
List<Repo> repos = RepoProvider.Helper.all(this); List<Repo> repos = RepoProvider.Helper.all(this);
//List<Repo> swapRepos = new ArrayList<>(); //List<Repo> swapRepos = new ArrayList<>();
List<Repo> unchangedRepos = new ArrayList<>(); int unchangedRepos = 0;
List<Repo> updatedRepos = new ArrayList<>(); int updatedRepos = 0;
List<CharSequence> errorRepos = new ArrayList<>(); int errorRepos = 0;
ArrayList<CharSequence> repoErrors = new ArrayList<>(); ArrayList<CharSequence> repoErrors = new ArrayList<>();
boolean changes = false; boolean changes = false;
boolean singleRepoUpdate = !TextUtils.isEmpty(address); boolean singleRepoUpdate = !TextUtils.isEmpty(address);
@ -362,7 +362,7 @@ public class UpdateService extends IntentService implements ProgressListener {
continue; continue;
} }
if (singleRepoUpdate && !repo.address.equals(address)) { if (singleRepoUpdate && !repo.address.equals(address)) {
unchangedRepos.add(repo); unchangedRepos++;
continue; continue;
} }
if (!singleRepoUpdate && repo.isSwap) { if (!singleRepoUpdate && repo.isSwap) {
@ -376,13 +376,13 @@ public class UpdateService extends IntentService implements ProgressListener {
try { try {
updater.update(); updater.update();
if (updater.hasChanged()) { if (updater.hasChanged()) {
updatedRepos.add(repo); updatedRepos++;
changes = true; changes = true;
} else { } else {
unchangedRepos.add(repo); unchangedRepos++;
} }
} catch (RepoUpdater.UpdateException e) { } catch (RepoUpdater.UpdateException e) {
errorRepos.add(repo.address); errorRepos++;
repoErrors.add(e.getMessage()); repoErrors.add(e.getMessage());
Log.e(TAG, "Error updating repository " + repo.address, e); Log.e(TAG, "Error updating repository " + repo.address, e);
} }
@ -403,14 +403,14 @@ public class UpdateService extends IntentService implements ProgressListener {
e.putLong(Preferences.PREF_UPD_LAST, System.currentTimeMillis()); e.putLong(Preferences.PREF_UPD_LAST, System.currentTimeMillis());
e.commit(); e.commit();
if (errorRepos.isEmpty()) { if (errorRepos == 0) {
if (changes) { if (changes) {
sendStatus(this, STATUS_COMPLETE_WITH_CHANGES); sendStatus(this, STATUS_COMPLETE_WITH_CHANGES);
} else { } else {
sendStatus(this, STATUS_COMPLETE_AND_SAME); sendStatus(this, STATUS_COMPLETE_AND_SAME);
} }
} else { } else {
if (updatedRepos.size() + unchangedRepos.size() == 0) { if (updatedRepos + unchangedRepos == 0) {
sendRepoErrorStatus(STATUS_ERROR_LOCAL, repoErrors); sendRepoErrorStatus(STATUS_ERROR_LOCAL, repoErrors);
} else { } else {
sendRepoErrorStatus(STATUS_ERROR_LOCAL_SMALL, repoErrors); sendRepoErrorStatus(STATUS_ERROR_LOCAL_SMALL, repoErrors);