Search in sources :

Example 1 with PodcastSearchResult

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);
}
Also used : Intent(android.content.Intent) PodcastSearchResult(de.danoeh.antennapod.discovery.PodcastSearchResult)

Example 2 with PodcastSearchResult

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;
}
Also used : ArrayList(java.util.ArrayList) FeedDiscoverAdapter(de.danoeh.antennapod.adapter.FeedDiscoverAdapter) MainActivity(de.danoeh.antennapod.activity.MainActivity) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) DisplayMetrics(android.util.DisplayMetrics) PodcastSearchResult(de.danoeh.antennapod.discovery.PodcastSearchResult)

Example 3 with PodcastSearchResult

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;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) FitCenter(com.bumptech.glide.load.resource.bitmap.FitCenter) MainActivity(de.danoeh.antennapod.activity.MainActivity) RoundedCorners(com.bumptech.glide.load.resource.bitmap.RoundedCorners) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) PodcastSearchResult(de.danoeh.antennapod.discovery.PodcastSearchResult) NonNull(androidx.annotation.NonNull)

Example 4 with PodcastSearchResult

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;
}
Also used : CombinedSearcher(de.danoeh.antennapod.discovery.CombinedSearcher) SpannableString(android.text.SpannableString) PodcastSearchResult(de.danoeh.antennapod.discovery.PodcastSearchResult)

Example 5 with PodcastSearchResult

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;
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) PodcastSearchResult(de.danoeh.antennapod.discovery.PodcastSearchResult)

Aggregations

PodcastSearchResult (de.danoeh.antennapod.discovery.PodcastSearchResult)8 View (android.view.View)4 TextView (android.widget.TextView)4 Intent (android.content.Intent)3 GridView (android.widget.GridView)3 ArrayList (java.util.ArrayList)3 AdapterView (android.widget.AdapterView)2 RequestOptions (com.bumptech.glide.request.RequestOptions)2 MainActivity (de.danoeh.antennapod.activity.MainActivity)2 ItunesAdapter (de.danoeh.antennapod.adapter.itunes.ItunesAdapter)2 SpannableString (android.text.SpannableString)1 DisplayMetrics (android.util.DisplayMetrics)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 AbsListView (android.widget.AbsListView)1 ArrayAdapter (android.widget.ArrayAdapter)1 ImageView (android.widget.ImageView)1 Spinner (android.widget.Spinner)1 NonNull (androidx.annotation.NonNull)1 SearchView (androidx.appcompat.widget.SearchView)1 Toolbar (androidx.appcompat.widget.Toolbar)1