use of de.danoeh.antennapod.discovery.PodcastSearchResult in project AntennaPod by AntennaPod.
the class QuickFeedDiscoveryFragment method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
PodcastSearchResult podcast = adapter.getItem(position);
if (podcast.feedUrl == null) {
return;
}
Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class);
intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, podcast.feedUrl);
startActivity(intent);
}
use of de.danoeh.antennapod.discovery.PodcastSearchResult in project AntennaPod by AntennaPod.
the class QuickFeedDiscoveryFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View root = inflater.inflate(R.layout.quick_feed_discovery, container, false);
View discoverMore = root.findViewById(R.id.discover_more);
discoverMore.setOnClickListener(v -> ((MainActivity) getActivity()).loadChildFragment(new DiscoveryFragment()));
discoverGridLayout = root.findViewById(R.id.discover_grid);
progressBar = root.findViewById(R.id.discover_progress_bar);
errorView = root.findViewById(R.id.discover_error);
errorTextView = root.findViewById(R.id.discover_error_txtV);
errorRetry = root.findViewById(R.id.discover_error_retry_btn);
errorRetry.setOnClickListener((listener) -> loadToplist());
poweredByTextView = root.findViewById(R.id.discover_powered_by_itunes);
adapter = new FeedDiscoverAdapter((MainActivity) getActivity());
discoverGridLayout.setAdapter(adapter);
discoverGridLayout.setOnItemClickListener(this);
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
float screenWidthDp = displayMetrics.widthPixels / displayMetrics.density;
if (screenWidthDp > 600) {
discoverGridLayout.setNumColumns(6);
} else {
discoverGridLayout.setNumColumns(4);
}
// Fill with dummy elements to have a fixed height and
// prevent the UI elements below from jumping on slow connections
List<PodcastSearchResult> dummies = new ArrayList<>();
for (int i = 0; i < NUM_SUGGESTIONS; i++) {
dummies.add(PodcastSearchResult.dummy());
}
adapter.updateData(dummies);
loadToplist();
EventBus.getDefault().register(this);
return root;
}
use of de.danoeh.antennapod.discovery.PodcastSearchResult in project AntennaPod by AntennaPod.
the class ItunesAdapter method getView.
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
// Current podcast
PodcastSearchResult podcast = data.get(position);
// ViewHolder
PodcastViewHolder viewHolder;
// Resulting view
View view;
// Handle view holder stuff
if (convertView == null) {
view = ((MainActivity) context).getLayoutInflater().inflate(R.layout.itunes_podcast_listitem, parent, false);
viewHolder = new PodcastViewHolder(view);
view.setTag(viewHolder);
} else {
view = convertView;
viewHolder = (PodcastViewHolder) view.getTag();
}
// Set the title
viewHolder.titleView.setText(podcast.title);
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.authorView.setVisibility(View.GONE);
}
// Update the empty imageView with the image from the feed
Glide.with(context).load(podcast.imageUrl).apply(new RequestOptions().placeholder(R.color.light_gray).diskCacheStrategy(DiskCacheStrategy.NONE).transforms(new FitCenter(), new RoundedCorners((int) (4 * context.getResources().getDisplayMetrics().density))).dontAnimate()).into(viewHolder.coverView);
// Feed the grid view
return view;
}
use of de.danoeh.antennapod.discovery.PodcastSearchResult in project AntennaPod by AntennaPod.
the class OnlineFeedViewActivity method searchFeedUrlByTrackName.
private String searchFeedUrlByTrackName(String trackName, String artistName) {
CombinedSearcher searcher = new CombinedSearcher();
String query = trackName + " " + artistName;
List<PodcastSearchResult> results = searcher.search(query).blockingGet();
for (PodcastSearchResult result : results) {
if (result.feedUrl != null && result.author != null && result.author.equalsIgnoreCase(artistName) && result.title.equalsIgnoreCase(trackName)) {
return result.feedUrl;
}
}
return null;
}
use of de.danoeh.antennapod.discovery.PodcastSearchResult in project AntennaPod by AntennaPod.
the class FeedDiscoverAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder;
if (convertView == null) {
convertView = View.inflate(mainActivityRef.get(), R.layout.quick_feed_discovery_item, null);
holder = new Holder();
holder.imageView = convertView.findViewById(R.id.discovery_cover);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
final PodcastSearchResult podcast = getItem(position);
holder.imageView.setContentDescription(podcast.title);
Glide.with(mainActivityRef.get()).load(podcast.imageUrl).apply(new RequestOptions().placeholder(R.color.light_gray).fitCenter().dontAnimate()).into(holder.imageView);
return convertView;
}
Aggregations