From c4250ccd352d0f059b70e879fb125803142abd2c Mon Sep 17 00:00:00 2001 From: greenart7c3 Date: Wed, 10 Apr 2024 14:11:11 -0300 Subject: [PATCH] fix error when not using proxy --- .../amethyst/ui/actions/ImageDownloader.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageDownloader.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageDownloader.kt index 5b04d65eb..e61c88ccd 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageDownloader.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageDownloader.kt @@ -37,7 +37,12 @@ class ImageDownloader { try { HttpURLConnection.setFollowRedirects(true) var url = URL(imageUrl) - var huc = url.openConnection(HttpClientManager.getDefaultProxy()) as HttpURLConnection + var huc = + if (HttpClientManager.getDefaultProxy() != null) { + url.openConnection(HttpClientManager.getDefaultProxy()) as HttpURLConnection + } else { + url.openConnection() as HttpURLConnection + } huc.instanceFollowRedirects = true var responseCode = huc.responseCode @@ -46,7 +51,12 @@ class ImageDownloader { // open the new connnection again url = URL(newUrl) - huc = url.openConnection(HttpClientManager.getDefaultProxy()) as HttpURLConnection + huc = + if (HttpClientManager.getDefaultProxy() != null) { + url.openConnection(HttpClientManager.getDefaultProxy()) as HttpURLConnection + } else { + url.openConnection() as HttpURLConnection + } responseCode = huc.responseCode }