diff --git a/src/de/danoeh/antennapod/fragment/ItemlistFragment.java b/src/de/danoeh/antennapod/fragment/ItemlistFragment.java index d6ef29fdd..282bb4d5c 100644 --- a/src/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/src/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -60,6 +60,8 @@ public class ItemlistFragment extends ListFragment { /** Argument for FeeditemlistAdapter */ protected boolean showFeedtitle; + private AsyncTask currentLoadTask; + public ItemlistFragment(boolean showFeedtitle) { super(); this.showFeedtitle = showFeedtitle; @@ -118,9 +120,19 @@ public class ItemlistFragment extends ListFragment { @Override public void onStart() { super.onStart(); + EventDistributor.getInstance().register(contentUpdate); loadData(); } + @Override + public void onDestroyView() { + super.onDestroyView(); + EventDistributor.getInstance().unregister(contentUpdate); + if (currentLoadTask != null) { + currentLoadTask.cancel(true); + } + } + protected void loadData() { final long feedId; if (feed == null) { @@ -168,6 +180,7 @@ public class ItemlistFragment extends ListFragment { } } }; + currentLoadTask = loadTask; loadTask.execute(feedId); } @@ -184,17 +197,6 @@ public class ItemlistFragment extends ListFragment { adapterCallback, showFeedtitle); } - @Override - public void onPause() { - super.onPause(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - EventDistributor.getInstance().unregister(contentUpdate); - } - @Override public void onResume() { super.onResume(); @@ -206,7 +208,6 @@ public class ItemlistFragment extends ListFragment { } }); updateProgressBarVisibility(); - EventDistributor.getInstance().register(contentUpdate); } @Override