use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast in project AntennaPod by AntennaPod.
the class PodcastListFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.gpodnet_podcast_list, container, false);
gridView = root.findViewById(R.id.gridView);
progressBar = root.findViewById(R.id.progressBar);
txtvError = root.findViewById(R.id.txtvError);
butRetry = root.findViewById(R.id.butRetry);
gridView.setOnItemClickListener((parent, view, position, id) -> onPodcastSelected((GpodnetPodcast) gridView.getAdapter().getItem(position)));
butRetry.setOnClickListener(v -> loadData());
loadData();
return root;
}
use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast in project AntennaPod by AntennaPod.
the class GpodnetPodcastSearcher method search.
public Single<List<PodcastSearchResult>> search(String query) {
return Single.create((SingleOnSubscribe<List<PodcastSearchResult>>) subscriber -> {
try {
GpodnetService service = new GpodnetService(AntennapodHttpClient.getHttpClient(), SynchronizationCredentials.getHosturl(), SynchronizationCredentials.getDeviceID(), SynchronizationCredentials.getUsername(), SynchronizationCredentials.getPassword());
List<GpodnetPodcast> gpodnetPodcasts = service.searchPodcasts(query, 0);
List<PodcastSearchResult> results = new ArrayList<>();
for (GpodnetPodcast podcast : gpodnetPodcasts) {
results.add(PodcastSearchResult.fromGpodder(podcast));
}
subscriber.onSuccess(results);
} catch (GpodnetServiceException e) {
e.printStackTrace();
subscriber.onError(e);
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
}
use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast in project AntennaPod by AntennaPod.
the class PodcastListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder;
GpodnetPodcast podcast = getItem(position);
// Inflate Layout
if (convertView == null) {
holder = new Holder();
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.gpodnet_podcast_listitem, parent, false);
holder.image = convertView.findViewById(R.id.imgvCover);
holder.title = convertView.findViewById(R.id.txtvTitle);
holder.subscribers = convertView.findViewById(R.id.txtvSubscribers);
holder.author = convertView.findViewById(R.id.txtvAuthor);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
if (StringUtils.isNotBlank(podcast.getLogoUrl())) {
Glide.with(convertView.getContext()).load(podcast.getLogoUrl()).apply(new RequestOptions().placeholder(R.color.light_gray).error(R.color.light_gray).diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY).transforms(new FitCenter(), new RoundedCorners((int) (4 * convertView.getContext().getResources().getDisplayMetrics().density))).dontAnimate()).into(holder.image);
}
holder.title.setText(podcast.getTitle());
holder.subscribers.setText(String.valueOf(podcast.getSubscribers()));
holder.author.setText(podcast.getAuthor());
return convertView;
}
use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetPodcast in project AntennaPod by AntennaPod.
the class GpodnetService method readPodcastFromJsonObject.
private GpodnetPodcast readPodcastFromJsonObject(JSONObject object) throws JSONException {
String url = object.getString("url");
String title;
Object titleObj = object.opt("title");
if (titleObj instanceof String) {
title = (String) titleObj;
} else {
title = url;
}
String description;
Object descriptionObj = object.opt("description");
if (descriptionObj instanceof String) {
description = (String) descriptionObj;
} else {
description = "";
}
int subscribers = object.getInt("subscribers");
Object logoUrlObj = object.opt("logo_url");
String logoUrl = (logoUrlObj instanceof String) ? (String) logoUrlObj : null;
if (logoUrl == null) {
Object scaledLogoUrl = object.opt("scaled_logo_url");
if (scaledLogoUrl instanceof String) {
logoUrl = (String) scaledLogoUrl;
}
}
String website = null;
Object websiteObj = object.opt("website");
if (websiteObj instanceof String) {
website = (String) websiteObj;
}
String mygpoLink = object.getString("mygpo_link");
String author = null;
Object authorObj = object.opt("author");
if (authorObj instanceof String) {
author = (String) authorObj;
}
return new GpodnetPodcast(url, title, description, subscribers, logoUrl, website, mygpoLink, author);
}
Aggregations