Use local file size if episode is downloaded
This commit is contained in:
parent
5608d228be
commit
65611129e1
|
@ -4,6 +4,7 @@ import android.app.IntentService;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -36,6 +37,12 @@ public class FeedMediaSizeService extends IntentService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long size = Integer.MIN_VALUE;
|
long size = Integer.MIN_VALUE;
|
||||||
|
if(media.isDownloaded()) {
|
||||||
|
File mediaFile = new File(media.getLocalMediaUrl());
|
||||||
|
if(mediaFile.exists()) {
|
||||||
|
size = mediaFile.length();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
HttpURLConnection conn = null;
|
HttpURLConnection conn = null;
|
||||||
try {
|
try {
|
||||||
URL url = new URL(media.getDownload_url());
|
URL url = new URL(media.getDownload_url());
|
||||||
|
@ -52,6 +59,7 @@ public class FeedMediaSizeService extends IntentService {
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
media.setSize(size);
|
media.setSize(size);
|
||||||
DBWriter.setFeedMedia(this, media);
|
DBWriter.setFeedMedia(this, media);
|
||||||
EventBus.getDefault().post(FeedMediaEvent.update(media));
|
EventBus.getDefault().post(FeedMediaEvent.update(media));
|
||||||
|
|
Loading…
Reference in New Issue