Prevent IllegalStateException when fragment is detached

This commit is contained in:
Martin Fietz 2016-01-13 19:07:16 +01:00
parent 95bb95fc89
commit d8721bc3d8
6 changed files with 16 additions and 1 deletions

View File

@ -190,6 +190,9 @@ public class AllEpisodesFragment extends Fragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(!isAdded()) {
return;
}
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded) { if (itemsLoaded) {
inflater.inflate(R.menu.new_episodes, menu); inflater.inflate(R.menu.new_episodes, menu);

View File

@ -111,6 +111,9 @@ public class DownloadLogFragment extends ListFragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(!isAdded()) {
return;
}
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded) { if (itemsLoaded) {
MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label); MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label);

View File

@ -243,7 +243,7 @@ public class ItemFragment extends Fragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(item == null) { if(!isAdded() || item == null) {
return; return;
} }
inflater.inflate(R.menu.feeditem_options, menu); inflater.inflate(R.menu.feeditem_options, menu);

View File

@ -194,6 +194,9 @@ public class ItemlistFragment extends ListFragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(!isAdded()) {
return;
}
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded) { if (itemsLoaded) {

View File

@ -148,6 +148,9 @@ public class PlaybackHistoryFragment extends ListFragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(!isAdded()) {
return;
}
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (itemsLoaded) { if (itemsLoaded) {
MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label); MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label);

View File

@ -235,6 +235,9 @@ public class QueueFragment extends Fragment {
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(!isAdded()) {
return;
}
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
if (queue != null) { if (queue != null) {
inflater.inflate(R.menu.queue, menu); inflater.inflate(R.menu.queue, menu);