use of de.danoeh.antennapod.discovery.ItunesTopListLoader in project AntennaPod by AntennaPod.
the class QuickFeedDiscoveryFragment method loadToplist.
private void loadToplist() {
progressBar.setVisibility(View.VISIBLE);
discoverGridLayout.setVisibility(View.INVISIBLE);
errorView.setVisibility(View.GONE);
errorRetry.setVisibility(View.INVISIBLE);
poweredByTextView.setVisibility(View.VISIBLE);
ItunesTopListLoader loader = new ItunesTopListLoader(getContext());
SharedPreferences prefs = getActivity().getSharedPreferences(ItunesTopListLoader.PREFS, MODE_PRIVATE);
String countryCode = prefs.getString(ItunesTopListLoader.PREF_KEY_COUNTRY_CODE, Locale.getDefault().getCountry());
if (countryCode.equals(ItunesTopListLoader.DISCOVER_HIDE_FAKE_COUNTRY_CODE)) {
errorTextView.setText(String.format(getResources().getString(R.string.discover_is_hidden), getResources().getString(R.string.discover_hide)));
errorView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
discoverGridLayout.setVisibility(View.INVISIBLE);
errorRetry.setVisibility(View.INVISIBLE);
poweredByTextView.setVisibility(View.INVISIBLE);
return;
}
disposable = loader.loadToplist(countryCode, NUM_SUGGESTIONS).subscribe(podcasts -> {
errorView.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
discoverGridLayout.setVisibility(View.VISIBLE);
if (podcasts.size() == 0) {
errorTextView.setText(getResources().getText(R.string.search_status_no_results));
errorView.setVisibility(View.VISIBLE);
discoverGridLayout.setVisibility(View.INVISIBLE);
} else {
adapter.updateData(podcasts);
}
}, error -> {
Log.e(TAG, Log.getStackTraceString(error));
errorTextView.setText(error.getLocalizedMessage());
errorView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
discoverGridLayout.setVisibility(View.INVISIBLE);
errorRetry.setVisibility(View.VISIBLE);
});
}
use of de.danoeh.antennapod.discovery.ItunesTopListLoader in project AntennaPod by AntennaPod.
the class DiscoveryFragment method loadToplist.
private void loadToplist(String country) {
if (disposable != null) {
disposable.dispose();
}
gridView.setVisibility(View.GONE);
txtvError.setVisibility(View.GONE);
butRetry.setVisibility(View.GONE);
txtvEmpty.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
if (country.equals(ItunesTopListLoader.DISCOVER_HIDE_FAKE_COUNTRY_CODE)) {
gridView.setVisibility(View.GONE);
txtvError.setVisibility(View.VISIBLE);
txtvError.setText(getResources().getString(R.string.discover_is_hidden));
butRetry.setVisibility(View.GONE);
txtvEmpty.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
} else {
ItunesTopListLoader loader = new ItunesTopListLoader(getContext());
disposable = loader.loadToplist(country, 25).subscribe(podcasts -> {
progressBar.setVisibility(View.GONE);
topList = podcasts;
updateData(topList);
}, error -> {
Log.e(TAG, Log.getStackTraceString(error));
progressBar.setVisibility(View.GONE);
txtvError.setText(error.getMessage());
txtvError.setVisibility(View.VISIBLE);
butRetry.setOnClickListener(v -> loadToplist(country));
butRetry.setVisibility(View.VISIBLE);
});
}
}
Aggregations