From 99588bb6f5d67fd6a0884dbddfb61c1a8cdf30b6 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sat, 23 Sep 2017 11:09:53 +0200 Subject: 2423 Handle empty feed url in itunes search result --- .../de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'app/src/main/java/de') diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java index e381b4651..f1f8be559 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/itunes/ItunesAdapter.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.adapter.itunes; import android.content.Context; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; @@ -69,7 +70,7 @@ public class ItunesAdapter extends ArrayAdapter { //Set the title viewHolder.titleView.setText(podcast.title); - if(!podcast.feedUrl.contains("itunes.apple.com")) { + if(podcast.feedUrl != null && !podcast.feedUrl.contains("itunes.apple.com")) { viewHolder.urlView.setText(podcast.feedUrl); viewHolder.urlView.setVisibility(View.VISIBLE); } else { @@ -102,14 +103,16 @@ public class ItunesAdapter extends ArrayAdapter { /** * URL of the podcast image */ + @Nullable public final String imageUrl; /** * URL of the podcast feed */ + @Nullable public final String feedUrl; - private Podcast(String title, String imageUrl, String feedUrl) { + private Podcast(String title, @Nullable String imageUrl, @Nullable String feedUrl) { this.title = title; this.imageUrl = imageUrl; this.feedUrl = feedUrl; @@ -122,9 +125,9 @@ public class ItunesAdapter extends ArrayAdapter { * @throws JSONException */ public static Podcast fromSearch(JSONObject json) throws JSONException { - String title = json.getString("collectionName"); - String imageUrl = json.getString("artworkUrl100"); - String feedUrl = json.getString("feedUrl"); + String title = json.optString("collectionName", ""); + String imageUrl = json.optString("artworkUrl100", null); + String feedUrl = json.optString("feedUrl", null); return new Podcast(title, imageUrl, feedUrl); } -- cgit v1.2.3