Merge pull request #1161 from mfietz/issue/1159-empty-url

Check that URL is not null (or empty) when retrieving file size
This commit is contained in:
Tom Hennen 2015-09-05 11:48:48 -04:00
commit af29d0992e
2 changed files with 16 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package de.danoeh.antennapod.adapter;
import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -52,13 +53,16 @@ public class AdapterUtils {
txtvPos.setText("{fa-spinner}");
Iconify.addIcons(txtvPos);
NetworkUtils.getFeedMediaSizeObservable(media)
.subscribe(size -> {
.subscribe(
size -> {
if (size > 0) {
txtvPos.setText(Converter.byteToString(size));
} else {
txtvPos.setText("");
}
});
}, error -> {
Log.e(TAG, Log.getStackTraceString(error));
});
} else {
txtvPos.setText("");
}

View File

@ -5,6 +5,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.text.TextUtils;
import android.util.Log;
import com.squareup.okhttp.OkHttpClient;
@ -108,9 +109,17 @@ public class NetworkUtils {
}
} else if (false == media.checkedOnSizeButUnknown()) {
// only query the network if we haven't already checked
String url = media.getDownload_url();
if(TextUtils.isEmpty(url)) {
subscriber.onNext(0L);
subscriber.onCompleted();
return;
}
OkHttpClient client = AntennapodHttpClient.getHttpClient();
Request.Builder httpReq = new Request.Builder()
.url(media.getDownload_url())
.url(url)
.header("Accept-Encoding", "identity")
.head();
try {