From 2d912929372eed3fa290e5e778028d9d3b046969 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Wed, 26 Jun 2019 08:27:19 +0200 Subject: Combined podcast search --- .../antennapod/adapter/itunes/ItunesAdapter.java | 84 ++-------------------- 1 file changed, 5 insertions(+), 79 deletions(-) (limited to 'app/src/main/java/de/danoeh/antennapod/adapter/itunes') 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 2cf17c85f..f5213e4ab 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,7 +2,6 @@ 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; @@ -13,18 +12,14 @@ import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.request.RequestOptions; -import de.danoeh.antennapod.core.glide.ApGlideSettings; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; +import de.danoeh.antennapod.discovery.PodcastSearchResult; import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.mfietz.fyydlin.SearchHit; -public class ItunesAdapter extends ArrayAdapter { +public class ItunesAdapter extends ArrayAdapter { /** * Related Context */ @@ -33,7 +28,7 @@ public class ItunesAdapter extends ArrayAdapter { /** * List holding the podcasts found in the search */ - private final List data; + private final List data; /** * Constructor. @@ -41,7 +36,7 @@ public class ItunesAdapter extends ArrayAdapter { * @param context Related context * @param objects Search result */ - public ItunesAdapter(Context context, List objects) { + public ItunesAdapter(Context context, List objects) { super(context, 0, objects); this.data = objects; this.context = context; @@ -51,7 +46,7 @@ public class ItunesAdapter extends ArrayAdapter { @Override public View getView(int position, View convertView, @NonNull ViewGroup parent) { //Current podcast - Podcast podcast = data.get(position); + PodcastSearchResult podcast = data.get(position); //ViewHolder PodcastViewHolder viewHolder; @@ -93,75 +88,6 @@ public class ItunesAdapter extends ArrayAdapter { return view; } - /** - * Represents an individual podcast on the iTunes Store. - */ - public static class Podcast { //TODO: Move this out eventually. Possibly to core.itunes.model - - /** - * The name of the podcast - */ - public final String title; - - /** - * URL of the podcast image - */ - @Nullable - public final String imageUrl; - /** - * URL of the podcast feed - */ - @Nullable - public final String feedUrl; - - - private Podcast(String title, @Nullable String imageUrl, @Nullable String feedUrl) { - this.title = title; - this.imageUrl = imageUrl; - this.feedUrl = feedUrl; - } - - /** - * Constructs a Podcast instance from a iTunes search result - * - * @param json object holding the podcast information - * @throws JSONException - */ - public static Podcast fromSearch(JSONObject json) { - String title = json.optString("collectionName", ""); - String imageUrl = json.optString("artworkUrl100", null); - String feedUrl = json.optString("feedUrl", null); - return new Podcast(title, imageUrl, feedUrl); - } - - public static Podcast fromSearch(SearchHit searchHit) { - return new Podcast(searchHit.getTitle(), searchHit.getThumbImageURL(), searchHit.getXmlUrl()); - } - - /** - * Constructs a Podcast instance from iTunes toplist entry - * - * @param json object holding the podcast information - * @throws JSONException - */ - public static Podcast fromToplist(JSONObject json) throws JSONException { - String title = json.getJSONObject("title").getString("label"); - String imageUrl = null; - JSONArray images = json.getJSONArray("im:image"); - for(int i=0; imageUrl == null && i < images.length(); i++) { - JSONObject image = images.getJSONObject(i); - String height = image.getJSONObject("attributes").getString("height"); - if(Integer.parseInt(height) >= 100) { - imageUrl = image.getString("label"); - } - } - String feedUrl = "https://itunes.apple.com/lookup?id=" + - json.getJSONObject("id").getJSONObject("attributes").getString("im:id"); - return new Podcast(title, imageUrl, feedUrl); - } - - } - /** * View holder object for the GridView */ -- cgit v1.2.3