diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2017-04-17 09:03:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-17 09:03:55 +0200 |
commit | dcb3b578ac56e4421e45a408899156d5225a1953 (patch) | |
tree | 8050822cf29a28474e1c9b9e12b9c820f35fe12a /app | |
parent | bd80e1c9c64056fcea8cb40d3c9ad32c5e60e75b (diff) | |
parent | 2826738940e441a6875985efe0fe299ebe89d7c9 (diff) | |
download | AntennaPod-dcb3b578ac56e4421e45a408899156d5225a1953.zip |
Merge pull request #2304 from ByteHamster/start-once
Only allow menu invalidations from active fragment
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java | 3 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/EpisodesFragment.java | 24 |
2 files changed, 17 insertions, 10 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java index ab8808093..bbfd1688d 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -80,6 +80,7 @@ public class AllEpisodesFragment extends Fragment { private boolean viewsCreated = false; private boolean isUpdatingFeeds; + protected boolean isMenuInvalidationAllowed = false; protected Subscription subscription; private LinearLayoutManager layoutManager; @@ -430,7 +431,7 @@ public class AllEpisodesFragment extends Fragment { Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]"); DownloaderUpdate update = event.update; downloaderList = update.downloaders; - if (isUpdatingFeeds != update.feedIds.length > 0) { + if (isMenuInvalidationAllowed && isUpdatingFeeds != update.feedIds.length > 0) { getActivity().supportInvalidateOptionsMenu(); } if(listAdapter != null && update.mediaIds.length > 0) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesFragment.java index f23981935..e2fbd91f3 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesFragment.java @@ -79,6 +79,11 @@ public class EpisodesFragment extends Fragment { public static class EpisodesPagerAdapter extends FragmentPagerAdapter { private final Resources resources; + private AllEpisodesFragment[] fragments = { + new NewEpisodesFragment(), + new AllEpisodesFragment(), + new FavoriteEpisodesFragment() + }; public EpisodesPagerAdapter(FragmentManager fm, Resources resources) { super(fm); @@ -87,15 +92,7 @@ public class EpisodesFragment extends Fragment { @Override public Fragment getItem(int position) { - switch (position) { - case POS_ALL_EPISODES: - return new AllEpisodesFragment(); - case POS_NEW_EPISODES: - return new NewEpisodesFragment(); - case POS_FAV_EPISODES: - return new FavoriteEpisodesFragment(); - } - return null; + return fragments[position]; } @Override @@ -116,5 +113,14 @@ public class EpisodesFragment extends Fragment { return super.getPageTitle(position); } } + + @Override + public void setPrimaryItem(ViewGroup container, int position, Object object) { + super.setPrimaryItem(container, position, object); + for (int i = 0; i < TOTAL_COUNT; i++) { + // Invalidating the OptionsMenu is only allowed for the currently active fragment + fragments[i].isMenuInvalidationAllowed = (i == position); + } + } } } |