Browse Source

Tiny download optimization

pull/70/head
Ezerous 5 years ago
parent
commit
1601380175
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java

4
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];

Loading…
Cancel
Save