@Override public boolean checkDistribution(Distribution distribution) throws IOException { if (!LocalArtifactStore.checkArtifact(downloadConfig, distribution)) { return LocalArtifactStore.store(downloadConfig, distribution, downloader.download(downloadConfig, distribution)); } return true; }
@Override public IArtifactStore build() { return new PostgresArtifactStore(get(DOWNLOAD_CONFIG), get(TEMP_DIR_FACTORY), get(EXECUTABLE_NAMING), get(DOWNLOADER)); } }
@Override public boolean checkDistribution(Distribution distribution) throws IOException { return store().checkDistribution(distribution); }
Downloader d = new Downloader(...); MyProgressListener l = new MyProgressListener(); l.downloader = d; d.addListener(l); d.run();
public class MyActivity extends Activity implements OnDownloadCompleteListener { private void startDownload() { //inside whatever method Downloader downloader = new Downloader(this); //'this' implements OnDownloadCompleteListener downloader.go(); } @Override public void onDownloadFinished(boolean success) { //implementation } }
@Override public ExtractedArtifactStoreBuilder download(DownloadConfig downloadConfig) { super.download(downloadConfig); return this; }
@Override public IArtifactStore build() { boolean useCache = get(USE_CACHE, true); logger.debug("Build ArtifactStore(useCache: {})", useCache); IArtifactStore artifactStore; artifactStore = new ArtifactStore(get(DOWNLOAD_CONFIG), get(TEMP_DIR_FACTORY), get(EXECUTABLE_NAMING), get(DOWNLOADER)); if (useCache) { artifactStore = new CachingArtifactStore(artifactStore); } return artifactStore; } }
@Override public ExtractedArtifactStoreBuilder tempDir(Directory tempDirFactory) { super.tempDir(tempDirFactory); return this; }
@Override public ExtractedArtifactStoreBuilder executableNaming(ITempNaming execNaming) { super.executableNaming(execNaming); return this; }
@Override public void run() { CachingArtifactStore.this.removeAll(); CachingArtifactStore.this.shutdownExecutor(); } }
@Override public IArtifactStore build() { return new CachedPostgresArtifactStore(get(DOWNLOAD_CONFIG), get(TEMP_DIR_FACTORY), get(EXECUTABLE_NAMING), get(DOWNLOADER)); }
@Override public ExtractedArtifactStoreBuilder downloader(IDownloader downloader) { super.downloader(downloader); return this; }
@Override public boolean checkDistribution(Distribution distribution) throws IOException { return LocalArtifactStore.checkArtifact(_downloadConfig, distribution) || LocalArtifactStore.store(_downloadConfig, distribution, _downloader.download(_downloadConfig, distribution)); }
@Override public ExtractedArtifactStoreBuilder download(IDownloadConfig downloadConfig) { super.download(downloadConfig); return this; }
@Override public IArtifactStore build() { boolean useCache = get(USE_CACHE, true); logger.debug("Build ArtifactStore(useCache: {})", useCache); IArtifactStore artifactStore; artifactStore = new ArtifactStore(get(DOWNLOAD_CONFIG), get(TEMP_DIR_FACTORY), get(EXECUTABLE_NAMING), get(DOWNLOADER)); if (useCache) { artifactStore = new CachingArtifactStore(artifactStore); } return artifactStore; } }
@Override public ExtractedArtifactStoreBuilder tempDir(IDirectory tempDirFactory) { super.tempDir(tempDirFactory); return this; }
@Override public boolean checkDistribution(Distribution distribution) throws IOException { return store().checkDistribution(distribution); }
@Override public void run() { CachingArtifactStore.this.removeAll(); CachingArtifactStore.this.shutdownExecutor(); } }
@Override public ExtractedArtifactStoreBuilder downloader(IDownloader downloader) { super.downloader(downloader); return this; }
@Override public boolean checkDistribution(Distribution distribution) throws IOException { if (!LocalArtifactStore.checkArtifact(_downloadConfig, distribution)) { return LocalArtifactStore.store(_downloadConfig, distribution, _downloader.download(_downloadConfig, distribution)); } return true; }