use of de.danoeh.antennapod.adapter.gpodnet.PodcastListAdapter in project AntennaPod by AntennaPod.
the class PodcastListFragment method loadData.
protected final void loadData() {
AsyncTask<Void, Void, List<GpodnetPodcast>> loaderTask = new AsyncTask<Void, Void, List<GpodnetPodcast>>() {
volatile Exception exception = null;
@Override
protected List<GpodnetPodcast> doInBackground(Void... params) {
GpodnetService service = null;
try {
service = new GpodnetService();
return loadPodcastData(service);
} catch (GpodnetServiceException e) {
exception = e;
e.printStackTrace();
return null;
} finally {
if (service != null) {
service.shutdown();
}
}
}
@Override
protected void onPostExecute(List<GpodnetPodcast> gpodnetPodcasts) {
super.onPostExecute(gpodnetPodcasts);
final Context context = getActivity();
if (context != null && gpodnetPodcasts != null && gpodnetPodcasts.size() > 0) {
PodcastListAdapter listAdapter = new PodcastListAdapter(context, 0, gpodnetPodcasts);
gridView.setAdapter(listAdapter);
listAdapter.notifyDataSetChanged();
progressBar.setVisibility(View.GONE);
gridView.setVisibility(View.VISIBLE);
txtvError.setVisibility(View.GONE);
butRetry.setVisibility(View.GONE);
} else if (context != null && gpodnetPodcasts != null) {
gridView.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
txtvError.setText(getString(R.string.search_status_no_results));
txtvError.setVisibility(View.VISIBLE);
butRetry.setVisibility(View.GONE);
} else if (context != null) {
gridView.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
txtvError.setText(getString(R.string.error_msg_prefix) + exception.getMessage());
txtvError.setVisibility(View.VISIBLE);
butRetry.setVisibility(View.VISIBLE);
}
}
@Override
protected void onPreExecute() {
super.onPreExecute();
gridView.setVisibility(View.GONE);
progressBar.setVisibility(View.VISIBLE);
txtvError.setVisibility(View.GONE);
butRetry.setVisibility(View.GONE);
}
};
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
loaderTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
loaderTask.execute();
}
}
Aggregations