From 1601380175166ca1642c309096b5b0c60b1fff0d Mon Sep 17 00:00:00 2001 From: Ezerous Date: Sat, 30 May 2020 18:44:20 +0300 Subject: [PATCH] Tiny download optimization --- .../thmmy/mthmmy/activities/downloads/DownloadsActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java index 95e0334c..2bb96af2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java @@ -159,7 +159,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. public void onLoadMore() { if (pagesLoaded < numberOfPages) { parsedDownloads.add(null); - downloadsAdapter.notifyItemInserted(parsedDownloads.size()); + downloadsAdapter.notifyItemInserted(parsedDownloads.size()); //This gets a warning - change it! //Load data parseDownloadPageTask = new ParseDownloadPageTask(); @@ -287,7 +287,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. OkHttpClient client = BaseApplication.getInstance().getClient(); String fileName = null; try { - Response response = client.newCall(new Request.Builder().url(download.getUrl()).build()).execute(); + Response response = client.newCall(new Request.Builder().url(download.getUrl()).head().build()).execute(); String contentDisposition = response.headers("Content-Disposition").toString(); //check if link provides an attachment if (contentDisposition.contains("attachment")) fileName = contentDisposition.split("\"")[1];