normalize null checks for ProgressListeners

This removes the RepoUpdater.isInteractive() method to normalize the code
used to check whether a ProgressListener is null throughout the project.
This commit is contained in:
Hans-Christoph Steiner 2014-02-25 15:00:55 -05:00 committed by Peter Serwylo
parent d9f9b682d4
commit 9588f30778

View File

@ -66,10 +66,6 @@ abstract public class RepoUpdater {
return apks; return apks;
} }
public boolean isInteractive() {
return progressListener != null;
}
/** /**
* For example, you may want to unzip a jar file to get the index inside, * For example, you may want to unzip a jar file to get the index inside,
* or if the file is not compressed, you can just return a reference to * or if the file is not compressed, you can just return a reference to
@ -88,7 +84,7 @@ abstract public class RepoUpdater {
downloader = new HttpDownloader(getIndexAddress(), context); downloader = new HttpDownloader(getIndexAddress(), context);
downloader.setETag(repo.lastetag); downloader.setETag(repo.lastetag);
if (isInteractive()) { if (progressListener != null) { // interactive session, show progress
downloader.setProgressListener(progressListener, downloader.setProgressListener(progressListener,
new ProgressListener.Event(PROGRESS_TYPE_DOWNLOAD, repo.address)); new ProgressListener.Event(PROGRESS_TYPE_DOWNLOAD, repo.address));
} }
@ -171,7 +167,7 @@ abstract public class RepoUpdater {
XMLReader reader = parser.getXMLReader(); XMLReader reader = parser.getXMLReader();
RepoXMLHandler handler = new RepoXMLHandler(repo, progressListener); RepoXMLHandler handler = new RepoXMLHandler(repo, progressListener);
if (isInteractive()) { if (progressListener != null) {
// Only bother spending the time to count the expected apps // Only bother spending the time to count the expected apps
// if we can show that to the user... // if we can show that to the user...
handler.setTotalAppCount(estimateAppCount(indexFile)); handler.setTotalAppCount(estimateAppCount(indexFile));