diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-07-26 12:35:43 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-07-26 12:35:43 +0200 |
commit | c1fbc59f1cc6f754b925082584106aa741ea0c39 (patch) | |
tree | 314bbc415435ab4756fa6bc366042cf21dee5b7e /src/de | |
parent | aca79dc5b9e03f9ca7ca6fa9fc235265002ed71c (diff) | |
download | AntennaPod-c1fbc59f1cc6f754b925082584106aa741ea0c39.zip |
Fixed IllegalStateExceptions in some Fragments
Diffstat (limited to 'src/de')
-rw-r--r-- | src/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java | 3 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java | 33 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java b/src/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java index ed304ad37..082fe93fc 100644 --- a/src/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java +++ b/src/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java @@ -68,6 +68,7 @@ public class CompletedDownloadsFragment extends ListFragment { listAdapter = null; viewCreated = false; feedItemDialog = null; + stopItemLoader(); } @Override @@ -103,6 +104,7 @@ public class CompletedDownloadsFragment extends ListFragment { listAdapter = new DownloadedEpisodesListAdapter(getActivity(), itemAccess); setListAdapter(listAdapter); } + setListShown(true); listAdapter.notifyDataSetChanged(); if (feedItemDialog != null) { boolean res = feedItemDialog.updateContent(queue, items); @@ -171,7 +173,6 @@ public class CompletedDownloadsFragment extends ListFragment { @Override protected void onPostExecute(Object[] results) { super.onPostExecute(results); - setListShown(true); if (results != null) { items = (List<FeedItem>) results[0]; queue = (QueueAccess) results[1]; diff --git a/src/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java b/src/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java index 863216157..2289862aa 100644 --- a/src/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java +++ b/src/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java @@ -11,18 +11,18 @@ import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.TextView; + +import java.util.ArrayList; +import java.util.List; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.fragment.SearchFragment; import de.danoeh.antennapod.gpoddernet.GpodnetService; import de.danoeh.antennapod.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.gpoddernet.model.GpodnetTag; import de.danoeh.antennapod.util.menuhandler.MenuItemUtils; import de.danoeh.antennapod.util.menuhandler.NavDrawerActivity; -import java.util.ArrayList; -import java.util.List; - public class TagListFragment extends ListFragment { private static final String TAG = "TagListFragment"; private static final int COUNT = 50; @@ -69,11 +69,26 @@ public class TagListFragment extends ListFragment { } }); - loadData(); + startLoadTask(); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + cancelLoadTask(); + } + + private AsyncTask<Void, Void, List<GpodnetTag>> loadTask; + + private void cancelLoadTask() { + if (loadTask != null && !loadTask.isCancelled()) { + loadTask.cancel(true); + } } - private void loadData() { - AsyncTask<Void, Void, List<GpodnetTag>> task = new AsyncTask<Void, Void, List<GpodnetTag>>() { + private void startLoadTask() { + cancelLoadTask(); + loadTask = new AsyncTask<Void, Void, List<GpodnetTag>>() { private Exception exception; @Override @@ -118,9 +133,9 @@ public class TagListFragment extends ListFragment { } }; if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD_MR1) { - task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + loadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { - task.execute(); + loadTask.execute(); } } } |