Search in sources :

Example 6 with GpodnetServiceException

use of de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException in project AntennaPod by AntennaPod.

the class TagListFragment method startLoadTask.

private void startLoadTask() {
    cancelLoadTask();
    loadTask = new AsyncTask<Void, Void, List<GpodnetTag>>() {

        private Exception exception;

        @Override
        protected List<GpodnetTag> doInBackground(Void... params) {
            GpodnetService service = new GpodnetService();
            try {
                return service.getTopTags(COUNT);
            } catch (GpodnetServiceException e) {
                e.printStackTrace();
                exception = e;
                return null;
            } finally {
                service.shutdown();
            }
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            setListShown(false);
        }

        @Override
        protected void onPostExecute(List<GpodnetTag> gpodnetTags) {
            super.onPostExecute(gpodnetTags);
            final Context context = getActivity();
            if (context != null) {
                if (gpodnetTags != null) {
                    setListAdapter(new TagListAdapter(context, android.R.layout.simple_list_item_1, gpodnetTags));
                } else if (exception != null) {
                    TextView txtvError = new TextView(getActivity());
                    txtvError.setText(exception.getMessage());
                    getListView().setEmptyView(txtvError);
                }
                setListShown(true);
            }
        }
    };
    if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
        loadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        loadTask.execute();
    }
}
Also used : Context(android.content.Context) GpodnetServiceException(de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException) GpodnetTag(de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag) TagListAdapter(de.danoeh.antennapod.adapter.gpodnet.TagListAdapter) GpodnetService(de.danoeh.antennapod.core.gpoddernet.GpodnetService) List(java.util.List) TextView(android.widget.TextView) GpodnetServiceException(de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException)

Aggregations

GpodnetService (de.danoeh.antennapod.core.gpoddernet.GpodnetService)6 GpodnetServiceException (de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException)6 AsyncTask (android.os.AsyncTask)3 TextView (android.widget.TextView)3 List (java.util.List)3 Context (android.content.Context)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 Button (android.widget.Button)2 EditText (android.widget.EditText)2 ProgressBar (android.widget.ProgressBar)2 DownloadRequestException (de.danoeh.antennapod.core.storage.DownloadRequestException)2 InputMethodManager (android.view.inputmethod.InputMethodManager)1 ArrayAdapter (android.widget.ArrayAdapter)1 Spinner (android.widget.Spinner)1 PodcastListAdapter (de.danoeh.antennapod.adapter.gpodnet.PodcastListAdapter)1 TagListAdapter (de.danoeh.antennapod.adapter.gpodnet.TagListAdapter)1 GpodnetDevice (de.danoeh.antennapod.core.gpoddernet.model.GpodnetDevice)1 GpodnetEpisodeAction (de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction)1 GpodnetEpisodeActionGetResponse (de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeActionGetResponse)1