Search in sources :

Example 1 with FeedDiscoverAdapter

use of de.danoeh.antennapod.adapter.FeedDiscoverAdapter 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)

Aggregations

DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 GridView (android.widget.GridView)1 TextView (android.widget.TextView)1 MainActivity (de.danoeh.antennapod.activity.MainActivity)1 FeedDiscoverAdapter (de.danoeh.antennapod.adapter.FeedDiscoverAdapter)1 PodcastSearchResult (de.danoeh.antennapod.discovery.PodcastSearchResult)1 ArrayList (java.util.ArrayList)1