Show artistName in place of podcast url when it is available (#3762)
This commit is contained in:
parent
05495d2110
commit
34fba016d1
|
@ -165,7 +165,7 @@ dependencies {
|
|||
implementation "com.github.shts:TriangleLabelView:$triangleLabelViewVersion"
|
||||
implementation 'com.leinardi.android:speed-dial:3.0.0'
|
||||
implementation "com.github.AntennaPod:AntennaPod-AudioPlayer:$audioPlayerVersion"
|
||||
implementation 'com.github.mfietz:fyydlin:v0.4.2'
|
||||
implementation 'com.github.mfietz:fyydlin:v0.5.0'
|
||||
implementation 'com.github.ByteHamster:SearchPreference:v2.0.0'
|
||||
|
||||
androidTestImplementation "org.awaitility:awaitility:$awaitilityVersion"
|
||||
|
|
|
@ -44,7 +44,7 @@ public class PodcastListAdapter extends ArrayAdapter<GpodnetPodcast> {
|
|||
holder.image = convertView.findViewById(R.id.imgvCover);
|
||||
holder.title = convertView.findViewById(R.id.txtvTitle);
|
||||
holder.subscribers = convertView.findViewById(R.id.txtvSubscribers);
|
||||
holder.url = convertView.findViewById(R.id.txtvUrl);
|
||||
holder.author = convertView.findViewById(R.id.txtvAuthor);
|
||||
convertView.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
|
@ -64,7 +64,7 @@ public class PodcastListAdapter extends ArrayAdapter<GpodnetPodcast> {
|
|||
|
||||
holder.title.setText(podcast.getTitle());
|
||||
holder.subscribers.setText(String.valueOf(podcast.getSubscribers()));
|
||||
holder.url.setText(podcast.getUrl());
|
||||
holder.author.setText(podcast.getAuthor());
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
@ -73,6 +73,6 @@ public class PodcastListAdapter extends ArrayAdapter<GpodnetPodcast> {
|
|||
ImageView image;
|
||||
TextView title;
|
||||
TextView subscribers;
|
||||
TextView url;
|
||||
TextView author;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,13 +65,16 @@ public class ItunesAdapter extends ArrayAdapter<PodcastSearchResult> {
|
|||
viewHolder = (PodcastViewHolder) view.getTag();
|
||||
}
|
||||
|
||||
//Set the title
|
||||
// Set the title
|
||||
viewHolder.titleView.setText(podcast.title);
|
||||
if(podcast.feedUrl != null && !podcast.feedUrl.contains("itunes.apple.com")) {
|
||||
viewHolder.urlView.setText(podcast.feedUrl);
|
||||
viewHolder.urlView.setVisibility(View.VISIBLE);
|
||||
if (podcast.author != null && ! podcast.author.trim().isEmpty()) {
|
||||
viewHolder.authorView.setText(podcast.author);
|
||||
viewHolder.authorView.setVisibility(View.VISIBLE);
|
||||
} else if (podcast.feedUrl != null && !podcast.feedUrl.contains("itunes.apple.com")) {
|
||||
viewHolder.authorView.setText(podcast.feedUrl);
|
||||
viewHolder.authorView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.urlView.setVisibility(View.GONE);
|
||||
viewHolder.authorView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//Update the empty imageView with the image from the feed
|
||||
|
@ -103,7 +106,7 @@ public class ItunesAdapter extends ArrayAdapter<PodcastSearchResult> {
|
|||
*/
|
||||
final TextView titleView;
|
||||
|
||||
final TextView urlView;
|
||||
final TextView authorView;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -113,7 +116,7 @@ public class ItunesAdapter extends ArrayAdapter<PodcastSearchResult> {
|
|||
PodcastViewHolder(View view){
|
||||
coverView = view.findViewById(R.id.imgvCover);
|
||||
titleView = view.findViewById(R.id.txtvTitle);
|
||||
urlView = view.findViewById(R.id.txtvUrl);
|
||||
authorView = view.findViewById(R.id.txtvAuthor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,15 +25,26 @@ public class PodcastSearchResult {
|
|||
@Nullable
|
||||
public final String feedUrl;
|
||||
|
||||
/**
|
||||
* artistName of the podcast feed
|
||||
*/
|
||||
@Nullable
|
||||
public final String author;
|
||||
|
||||
private PodcastSearchResult(String title, @Nullable String imageUrl, @Nullable String feedUrl) {
|
||||
|
||||
private PodcastSearchResult(String title, @Nullable String imageUrl, @Nullable String feedUrl, @Nullable String author) {
|
||||
this.title = title;
|
||||
this.imageUrl = imageUrl;
|
||||
this.feedUrl = feedUrl;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
private PodcastSearchResult(String title, @Nullable String imageUrl, @Nullable String feedUrl) {
|
||||
this(title, imageUrl, feedUrl, "");
|
||||
}
|
||||
|
||||
public static PodcastSearchResult dummy() {
|
||||
return new PodcastSearchResult("", "", "");
|
||||
return new PodcastSearchResult("", "", "", "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +57,8 @@ public class PodcastSearchResult {
|
|||
String title = json.optString("collectionName", "");
|
||||
String imageUrl = json.optString("artworkUrl100", null);
|
||||
String feedUrl = json.optString("feedUrl", null);
|
||||
return new PodcastSearchResult(title, imageUrl, feedUrl);
|
||||
String author = json.optString("artistName", null);
|
||||
return new PodcastSearchResult(title, imageUrl, feedUrl, author);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,14 +80,27 @@ public class PodcastSearchResult {
|
|||
}
|
||||
String feedUrl = "https://itunes.apple.com/lookup?id=" +
|
||||
json.getJSONObject("id").getJSONObject("attributes").getString("im:id");
|
||||
return new PodcastSearchResult(title, imageUrl, feedUrl);
|
||||
|
||||
String author = null;
|
||||
try {
|
||||
author = json.getJSONObject("im:artist").getString("label");
|
||||
} catch (Exception e) {
|
||||
// Some feeds have empty artist
|
||||
}
|
||||
return new PodcastSearchResult(title, imageUrl, feedUrl, author);
|
||||
}
|
||||
|
||||
public static PodcastSearchResult fromFyyd(SearchHit searchHit) {
|
||||
return new PodcastSearchResult(searchHit.getTitle(), searchHit.getThumbImageURL(), searchHit.getXmlUrl());
|
||||
return new PodcastSearchResult(searchHit.getTitle(),
|
||||
searchHit.getThumbImageURL(),
|
||||
searchHit.getXmlUrl(),
|
||||
searchHit.getAuthor());
|
||||
}
|
||||
|
||||
public static PodcastSearchResult fromGpodder(GpodnetPodcast searchHit) {
|
||||
return new PodcastSearchResult(searchHit.getTitle(), searchHit.getLogoUrl(), searchHit.getUrl());
|
||||
return new PodcastSearchResult(searchHit.getTitle(),
|
||||
searchHit.getLogoUrl(),
|
||||
searchHit.getUrl(),
|
||||
searchHit.getAuthor());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
tools:background="@android:color/holo_green_dark" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvUrl"
|
||||
android:id="@+id/txtvAuthor"
|
||||
style="android:style/TextAppearance.Small"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -81,7 +81,7 @@
|
|||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:ellipsize="middle"
|
||||
android:maxLines="2"
|
||||
tools:text="http://www.example.com/feed"
|
||||
tools:text="author"
|
||||
tools:background="@android:color/holo_green_dark"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
tools:text="Podcast title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvUrl"
|
||||
android:id="@+id/txtvAuthor"
|
||||
style="android:style/TextAppearance.Small"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -53,7 +53,7 @@
|
|||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:ellipsize="middle"
|
||||
android:maxLines="2"
|
||||
tools:text="http://www.example.com/feed"
|
||||
tools:text="author"
|
||||
tools:background="@android:color/holo_green_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -52,4 +52,4 @@
|
|||
tools:background="@android:color/holo_blue_light"/>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -688,8 +688,20 @@ public class GpodnetService {
|
|||
website = (String) websiteObj;
|
||||
}
|
||||
String mygpoLink = object.getString("mygpo_link");
|
||||
return new GpodnetPodcast(url, title, description, subscribers,
|
||||
logoUrl, website, mygpoLink);
|
||||
|
||||
String author = null;
|
||||
Object authorObj = object.opt("author");
|
||||
if (authorObj != null && authorObj instanceof String) {
|
||||
author = (String) authorObj;
|
||||
}
|
||||
return new GpodnetPodcast(url,
|
||||
title,
|
||||
description,
|
||||
subscribers,
|
||||
logoUrl,
|
||||
website,
|
||||
mygpoLink,
|
||||
author);
|
||||
}
|
||||
|
||||
private List<GpodnetDevice> readDeviceListFromJSONArray(@NonNull JSONArray array)
|
||||
|
|
|
@ -10,6 +10,7 @@ public class GpodnetPodcast {
|
|||
private final String logoUrl;
|
||||
private final String website;
|
||||
private final String mygpoLink;
|
||||
private final String author;
|
||||
|
||||
public GpodnetPodcast(@NonNull String url,
|
||||
@NonNull String title,
|
||||
|
@ -17,7 +18,9 @@ public class GpodnetPodcast {
|
|||
int subscribers,
|
||||
String logoUrl,
|
||||
String website,
|
||||
String mygpoLink) {
|
||||
String mygpoLink,
|
||||
String author
|
||||
) {
|
||||
this.url = url;
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
|
@ -25,6 +28,7 @@ public class GpodnetPodcast {
|
|||
this.logoUrl = logoUrl;
|
||||
this.website = website;
|
||||
this.mygpoLink = mygpoLink;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,6 +63,8 @@ public class GpodnetPodcast {
|
|||
return website;
|
||||
}
|
||||
|
||||
public String getAuthor() { return author; }
|
||||
|
||||
public String getMygpoLink() {
|
||||
return mygpoLink;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue