further simplification of Downloader based on Uri

missed this in df08e84e7829652d7999eee5451080a012b00a1e
This commit is contained in:
Hans-Christoph Steiner 2018-03-30 10:54:25 +02:00
parent 401d094af1
commit 3f3ff5ffd7
2 changed files with 4 additions and 11 deletions

View File

@ -82,8 +82,7 @@ public class IndexV1Updater extends RepoUpdater {
Downloader downloader = null; Downloader downloader = null;
try { try {
// read file name from file // read file name from file
final Uri dataUri = Uri.parse(indexUrl); downloader = DownloaderFactory.create(context, indexUrl);
downloader = DownloaderFactory.create(context, dataUri.toString());
downloader.setCacheTag(repo.lastetag); downloader.setCacheTag(repo.lastetag);
downloader.setListener(downloadListener); downloader.setListener(downloadListener);
downloader.download(); downloader.download();
@ -108,8 +107,7 @@ public class IndexV1Updater extends RepoUpdater {
try { try {
mirrorUrl = FDroidApp.getMirror(prevMirrorUrl, repo); mirrorUrl = FDroidApp.getMirror(prevMirrorUrl, repo);
prevMirrorUrl = mirrorUrl; prevMirrorUrl = mirrorUrl;
Uri dataUri2 = Uri.parse(mirrorUrl); downloader = DownloaderFactory.create(context, mirrorUrl);
downloader = DownloaderFactory.create(context, dataUri2.toString());
downloader.setCacheTag(repo.lastetag); downloader.setCacheTag(repo.lastetag);
downloader.setListener(downloadListener); downloader.setListener(downloadListener);
downloader.setTimeout(FDroidApp.getTimeout()); downloader.setTimeout(FDroidApp.getTimeout());

View File

@ -20,19 +20,14 @@ public class DownloaderFactory {
throws IOException { throws IOException {
File destFile = File.createTempFile("dl-", "", context.getCacheDir()); File destFile = File.createTempFile("dl-", "", context.getCacheDir());
destFile.deleteOnExit(); // this probably does nothing, but maybe... destFile.deleteOnExit(); // this probably does nothing, but maybe...
return create(context, urlString, destFile); Uri uri = Uri.parse(urlString);
return create(context, uri, destFile);
} }
public static Downloader create(Context context, Uri uri, File destFile) public static Downloader create(Context context, Uri uri, File destFile)
throws IOException { throws IOException {
return create(context, uri.toString(), destFile);
}
public static Downloader create(Context context, String urlString, File destFile)
throws IOException {
Downloader downloader; Downloader downloader;
Uri uri = Uri.parse(urlString);
String scheme = uri.getScheme(); String scheme = uri.getScheme();
if ("bluetooth".equals(scheme)) { if ("bluetooth".equals(scheme)) {
downloader = new BluetoothDownloader(uri, destFile); downloader = new BluetoothDownloader(uri, destFile);