From 1fe2a8da456a3fbf3752c7a8ae218891b632d552 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Tue, 22 Apr 2014 13:55:20 +0200 Subject: Resolved dialog issues + fragment crashes --- .../fragment/CompletedDownloadsFragment.java | 5 +++++ .../danoeh/antennapod/fragment/ItemlistFragment.java | 8 ++++++-- .../antennapod/fragment/NewEpisodesFragment.java | 7 +++---- .../antennapod/fragment/PlaybackHistoryFragment.java | 19 ++++++++++++------- src/de/danoeh/antennapod/fragment/QueueFragment.java | 15 +++++++-------- src/de/danoeh/antennapod/fragment/SearchFragment.java | 7 ++++++- 6 files changed, 39 insertions(+), 22 deletions(-) (limited to 'src/de/danoeh/antennapod/fragment') diff --git a/src/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java b/src/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java index fe661a38a..51c92e234 100644 --- a/src/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java +++ b/src/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java @@ -53,6 +53,11 @@ public class CompletedDownloadsFragment extends ListFragment { public void onDetach() { super.onDetach(); stopItemLoader(); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); listAdapter = null; viewCreated = false; } diff --git a/src/de/danoeh/antennapod/fragment/ItemlistFragment.java b/src/de/danoeh/antennapod/fragment/ItemlistFragment.java index 8a958c758..c3533bff5 100644 --- a/src/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/src/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -118,7 +118,6 @@ public class ItemlistFragment extends ListFragment { super.onStop(); EventDistributor.getInstance().unregister(contentUpdate); stopItemLoader(); - resetViewState(); } @Override @@ -131,6 +130,11 @@ public class ItemlistFragment extends ListFragment { public void onDetach() { super.onDetach(); stopItemLoader(); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); resetViewState(); } @@ -233,7 +237,7 @@ public class ItemlistFragment extends ListFragment { @Override public void onListItemClick(ListView l, View v, int position, long id) { FeedItem selection = adapter.getItem(position - l.getHeaderViewsCount()); - feedItemDialog = new FeedItemDialog(getActivity(), selection, queue); + feedItemDialog = FeedItemDialog.newInstace(getActivity(), selection, queue); feedItemDialog.show(); } diff --git a/src/de/danoeh/antennapod/fragment/NewEpisodesFragment.java b/src/de/danoeh/antennapod/fragment/NewEpisodesFragment.java index 05ac37554..ae4083c86 100644 --- a/src/de/danoeh/antennapod/fragment/NewEpisodesFragment.java +++ b/src/de/danoeh/antennapod/fragment/NewEpisodesFragment.java @@ -100,7 +100,6 @@ public class NewEpisodesFragment extends Fragment { super.onStop(); EventDistributor.getInstance().unregister(contentUpdate); stopItemLoader(); - resetViewState(); } @Override @@ -110,8 +109,8 @@ public class NewEpisodesFragment extends Fragment { } @Override - public void onDetach() { - super.onDetach(); + public void onDestroyView() { + super.onDestroyView(); resetViewState(); } @@ -192,7 +191,7 @@ public class NewEpisodesFragment extends Fragment { public void onItemClick(AdapterView parent, View view, int position, long id) { FeedItem item = (FeedItem) listAdapter.getItem(position - listView.getHeaderViewsCount()); if (item != null) { - feedItemDialog = new FeedItemDialog(activity.get(), item, queueAccess); + feedItemDialog = FeedItemDialog.newInstace(activity.get(), item, queueAccess); feedItemDialog.show(); } diff --git a/src/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java b/src/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java index c4e02c5f0..2abc7a9fb 100644 --- a/src/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java +++ b/src/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java @@ -73,13 +73,7 @@ public class PlaybackHistoryFragment extends ListFragment { public void onDetach() { super.onDetach(); stopItemLoader(); - adapter = null; - viewsCreated = false; activity.set(null); - if (downloadObserver != null) { - downloadObserver.onPause(); - } - feedItemDialog = null; } @Override @@ -95,6 +89,17 @@ public class PlaybackHistoryFragment extends ListFragment { } } + @Override + public void onDestroyView() { + super.onDestroyView(); + adapter = null; + viewsCreated = false; + if (downloadObserver != null) { + downloadObserver.onPause(); + } + feedItemDialog = null; + } + @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); @@ -109,7 +114,7 @@ public class PlaybackHistoryFragment extends ListFragment { super.onListItemClick(l, v, position, id); FeedItem item = adapter.getItem(position - l.getHeaderViewsCount()); if (item != null) { - feedItemDialog = new FeedItemDialog(activity.get(), item, queue); + feedItemDialog = FeedItemDialog.newInstace(activity.get(), item, queue); feedItemDialog.show(); } } diff --git a/src/de/danoeh/antennapod/fragment/QueueFragment.java b/src/de/danoeh/antennapod/fragment/QueueFragment.java index 838da7e6a..13f21e3c8 100644 --- a/src/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/src/de/danoeh/antennapod/fragment/QueueFragment.java @@ -96,7 +96,6 @@ public class QueueFragment extends Fragment { super.onStop(); EventDistributor.getInstance().unregister(contentUpdate); stopItemLoader(); - resetViewState(); } @Override @@ -105,12 +104,6 @@ public class QueueFragment extends Fragment { this.activity.set((MainActivity) activity); } - @Override - public void onDetach() { - super.onDetach(); - resetViewState(); - } - private void resetViewState() { listAdapter = null; undoBarController = null; @@ -123,6 +116,12 @@ public class QueueFragment extends Fragment { feedItemDialog = null; } + @Override + public void onDestroyView() { + super.onDestroyView(); + resetViewState(); + } + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); @@ -160,7 +159,7 @@ public class QueueFragment extends Fragment { public void onItemClick(AdapterView parent, View view, int position, long id) { FeedItem item = (FeedItem) listAdapter.getItem(position - listView.getHeaderViewsCount()); if (item != null) { - feedItemDialog = new FeedItemDialog(activity.get(), item, QueueAccess.ItemListAccess(queue)); + feedItemDialog = FeedItemDialog.newInstace(activity.get(), item, QueueAccess.ItemListAccess(queue)); feedItemDialog.show(); } } diff --git a/src/de/danoeh/antennapod/fragment/SearchFragment.java b/src/de/danoeh/antennapod/fragment/SearchFragment.java index 268e36c37..566695465 100644 --- a/src/de/danoeh/antennapod/fragment/SearchFragment.java +++ b/src/de/danoeh/antennapod/fragment/SearchFragment.java @@ -89,6 +89,11 @@ public class SearchFragment extends ListFragment { public void onDetach() { super.onDetach(); stopSearchTask(); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); searchAdapter = null; viewCreated = false; } @@ -112,7 +117,7 @@ public class SearchFragment extends ListFragment { ((MainActivity)getActivity()).loadFeedFragment(comp.getId()); } else { if (comp.getClass() == FeedItem.class) { - feedItemDialog = new FeedItemDialog(getActivity(), (FeedItem) comp, queue); + feedItemDialog = FeedItemDialog.newInstace(getActivity(), (FeedItem) comp, queue); feedItemDialog.show(); } } -- cgit v1.2.3