From 9c2f46e5e4059fe32362d9ad8dafb06372cb8f3e Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sat, 18 Apr 2015 22:12:26 +0200 Subject: [PATCH] Remove checks for opened drawer, now unneccessary --- .../activity/AudioplayerActivity.java | 34 ++----------- .../antennapod/activity/MainActivity.java | 19 +------ .../fragment/AllEpisodesFragment.java | 4 +- .../fragment/DownloadLogFragment.java | 11 +++-- .../antennapod/fragment/ItemlistFragment.java | 4 +- .../fragment/PlaybackHistoryFragment.java | 6 +-- .../antennapod/fragment/QueueFragment.java | 2 +- .../antennapod/fragment/SearchFragment.java | 4 +- .../fragment/gpodnet/PodcastListFragment.java | 49 ++++++++++--------- .../fragment/gpodnet/SearchListFragment.java | 33 ++++++------- .../fragment/gpodnet/TagListFragment.java | 37 +++++++------- 11 files changed, 77 insertions(+), 126 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index 3c6caa787..972d318fb 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -46,7 +46,6 @@ import de.danoeh.antennapod.core.util.playback.PlaybackController; import de.danoeh.antennapod.dialog.VariableSpeedDialog; import de.danoeh.antennapod.fragment.CoverFragment; import de.danoeh.antennapod.fragment.ItemDescriptionFragment; -import de.danoeh.antennapod.menuhandler.MenuItemUtils; import de.danoeh.antennapod.menuhandler.NavDrawerActivity; import de.danoeh.antennapod.preferences.PreferenceController; @@ -413,26 +412,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc butShowCover = (ImageButton) findViewById(R.id.butCover); txtvTitle = (TextView) findViewById(R.id.txtvTitle); - /* - drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close) { - CharSequence currentTitle = getSupportActionBar().getTitle(); - - @Override - public void onDrawerOpened(View drawerView) { - super.onDrawerOpened(drawerView); - currentTitle = getSupportActionBar().getTitle(); - getSupportActionBar().setTitle(R.string.app_name); - supportInvalidateOptionsMenu(); - } - - @Override - public void onDrawerClosed(View drawerView) { - super.onDrawerClosed(drawerView); - getSupportActionBar().setTitle(currentTitle); - supportInvalidateOptionsMenu(); - } - }; */ - + drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close); drawerToggle.setDrawerIndicatorEnabled(false); drawerLayout.setDrawerListener(drawerToggle); @@ -638,20 +618,12 @@ public class AudioplayerActivity extends MediaplayerActivity implements ItemDesc @Override public boolean onCreateOptionsMenu(Menu menu) { - if (!MenuItemUtils.isActivityDrawerOpen(this)) { - return super.onCreateOptionsMenu(menu); - } else { - return false; - } + return super.onCreateOptionsMenu(menu); } @Override public boolean onPrepareOptionsMenu(Menu menu) { - if (!MenuItemUtils.isActivityDrawerOpen(this)) { - return super.onPrepareOptionsMenu(menu); - } else { - return false; - } + return super.onPrepareOptionsMenu(menu); } public interface AudioplayerContentFragment { diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index a13b1f836..759ada37c 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -113,28 +113,11 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity navList = (ListView) findViewById(R.id.nav_list); navDrawer = findViewById(R.id.nav_layout); - drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close) { - @Override - public void onDrawerOpened(View drawerView) { - super.onDrawerOpened(drawerView); - //currentTitle = getSupportActionBar().getTitle(); - //getSupportActionBar().setTitle(drawerTitle); - //supportInvalidateOptionsMenu(); - } - - @Override - public void onDrawerClosed(View drawerView) { - super.onDrawerClosed(drawerView); - //getSupportActionBar().setTitle(currentTitle); - //supportInvalidateOptionsMenu(); - } - }; - + drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.drawer_open, R.string.drawer_close); if (savedInstanceState != null) { int backstackCount = savedInstanceState.getInt(SAVE_BACKSTACK_COUNT, 0); drawerToggle.setDrawerIndicatorEnabled(backstackCount == 0); } - drawerLayout.setDrawerListener(drawerToggle); final FragmentManager fm = getSupportFragmentManager(); 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 3db2a82a7..6cd78da50 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -194,7 +194,7 @@ public class AllEpisodesFragment extends Fragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { + if (itemsLoaded) { inflater.inflate(R.menu.new_episodes, menu); final SearchView sv = new SearchView(getActivity()); @@ -220,7 +220,7 @@ public class AllEpisodesFragment extends Fragment { @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { + if (itemsLoaded) { MenuItem menuItem = menu.findItem(R.id.mark_all_read_item); if (menuItem != null) { menuItem.setVisible(unreadItems != null && !unreadItems.isEmpty()); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java index 0f6f7d53c..074a87ea0 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java @@ -20,8 +20,6 @@ import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.service.download.DownloadStatus; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; -import de.danoeh.antennapod.menuhandler.MenuItemUtils; -import de.danoeh.antennapod.menuhandler.NavDrawerActivity; /** * Shows the download log @@ -119,7 +117,7 @@ public class DownloadLogFragment extends ListFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { + if (itemsLoaded) { MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label); MenuItemCompat.setShowAsAction(clearHistory, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.content_discard}); @@ -131,8 +129,11 @@ public class DownloadLogFragment extends ListFragment { @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { - menu.findItem(R.id.clear_history_item).setVisible(downloadLog != null && !downloadLog.isEmpty()); + if (itemsLoaded) { + MenuItem menuItem = menu.findItem(R.id.clear_history_item); + if(menuItem != null) { + menuItem.setVisible(downloadLog != null && !downloadLog.isEmpty()); + } } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java index 9b8d1e632..f872284a4 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -180,7 +180,7 @@ public class ItemlistFragment extends ListFragment { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { + if (itemsLoaded) { FeedMenuHandler.onCreateOptionsMenu(inflater, menu); final SearchView sv = new SearchView(getActivity()); @@ -207,7 +207,7 @@ public class ItemlistFragment extends ListFragment { @Override public void onPrepareOptionsMenu(Menu menu) { - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { + if (itemsLoaded) { FeedMenuHandler.onPrepareOptionsMenu(menu, feed); } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java index 413c1fea4..440e38636 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java @@ -32,8 +32,6 @@ import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.util.LongList; -import de.danoeh.antennapod.menuhandler.MenuItemUtils; -import de.danoeh.antennapod.menuhandler.NavDrawerActivity; import de.greenrobot.event.EventBus; public class PlaybackHistoryFragment extends ListFragment { @@ -141,7 +139,7 @@ public class PlaybackHistoryFragment extends ListFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { + if (itemsLoaded) { MenuItem clearHistory = menu.add(Menu.NONE, R.id.clear_history_item, Menu.CATEGORY_CONTAINER, R.string.clear_history_label); MenuItemCompat.setShowAsAction(clearHistory, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); TypedArray drawables = getActivity().obtainStyledAttributes(new int[]{R.attr.content_discard}); @@ -153,7 +151,7 @@ public class PlaybackHistoryFragment extends ListFragment { @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { + if (itemsLoaded) { MenuItem menuItem = menu.findItem(R.id.clear_history_item); if (menuItem != null) { menuItem.setVisible(playbackHistory != null && !playbackHistory.isEmpty()); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index 8ebb21469..f1ed6c656 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -202,7 +202,7 @@ public class QueueFragment extends Fragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { + if (itemsLoaded) { inflater.inflate(R.menu.queue, menu); final SearchView sv = new SearchView(getActivity()); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java index a30e648a1..fc6225409 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java @@ -25,8 +25,6 @@ import de.danoeh.antennapod.core.feed.FeedComponent; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.SearchResult; import de.danoeh.antennapod.core.storage.FeedSearcher; -import de.danoeh.antennapod.menuhandler.MenuItemUtils; -import de.danoeh.antennapod.menuhandler.NavDrawerActivity; /** * Performs a search operation on all feeds or one specific feed and displays the search result. @@ -134,7 +132,7 @@ public class SearchFragment extends ListFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - if (itemsLoaded && !MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { + if (itemsLoaded) { MenuItem item = menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); final SearchView sv = new SearchView(getActivity()); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java index 15a0b55b1..c87ed777c 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java @@ -6,8 +6,18 @@ import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; -import android.view.*; -import android.widget.*; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.Button; +import android.widget.GridView; +import android.widget.ProgressBar; +import android.widget.TextView; + +import java.util.List; import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; @@ -19,9 +29,6 @@ import de.danoeh.antennapod.core.gpoddernet.GpodnetService; import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast; import de.danoeh.antennapod.menuhandler.MenuItemUtils; -import de.danoeh.antennapod.menuhandler.NavDrawerActivity; - -import java.util.List; /** * Displays a list of GPodnetPodcast-Objects in a GridView @@ -43,24 +50,22 @@ public abstract class PodcastListFragment extends Fragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - if (!MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { - final android.support.v7.widget.SearchView sv = new android.support.v7.widget.SearchView(getActivity()); - MenuItemUtils.addSearchItem(menu, sv); - sv.setQueryHint(getString(R.string.gpodnet_search_hint)); - sv.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() { - @Override - public boolean onQueryTextSubmit(String s) { - sv.clearFocus(); - ((MainActivity) getActivity()).loadChildFragment(SearchListFragment.newInstance(s)); - return true; - } + final android.support.v7.widget.SearchView sv = new android.support.v7.widget.SearchView(getActivity()); + MenuItemUtils.addSearchItem(menu, sv); + sv.setQueryHint(getString(R.string.gpodnet_search_hint)); + sv.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String s) { + sv.clearFocus(); + ((MainActivity) getActivity()).loadChildFragment(SearchListFragment.newInstance(s)); + return true; + } - @Override - public boolean onQueryTextChange(String s) { - return false; - } - }); - } + @Override + public boolean onQueryTextChange(String s) { + return false; + } + }); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/SearchListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/SearchListFragment.java index 635842196..2295ddf41 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/SearchListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/SearchListFragment.java @@ -14,7 +14,6 @@ import de.danoeh.antennapod.core.gpoddernet.GpodnetService; import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast; import de.danoeh.antennapod.menuhandler.MenuItemUtils; -import de.danoeh.antennapod.menuhandler.NavDrawerActivity; /** * Performs a search on the gpodder.net directory and displays the results. @@ -46,24 +45,22 @@ public class SearchListFragment extends PodcastListFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { final SearchView sv = new SearchView(getActivity()); - if (!MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { - MenuItemUtils.addSearchItem(menu, sv); - sv.setQueryHint(getString(R.string.gpodnet_search_hint)); - sv.setQuery(query, false); - sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { - @Override - public boolean onQueryTextSubmit(String s) { - sv.clearFocus(); - changeQuery(s); - return true; - } + MenuItemUtils.addSearchItem(menu, sv); + sv.setQueryHint(getString(R.string.gpodnet_search_hint)); + sv.setQuery(query, false); + sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String s) { + sv.clearFocus(); + changeQuery(s); + return true; + } - @Override - public boolean onQueryTextChange(String s) { - return false; - } - }); - } + @Override + public boolean onQueryTextChange(String s) { + return false; + } + }); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java index cc87407b4..6dff496b2 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java @@ -21,7 +21,6 @@ import de.danoeh.antennapod.core.gpoddernet.GpodnetService; import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetTag; import de.danoeh.antennapod.menuhandler.MenuItemUtils; -import de.danoeh.antennapod.menuhandler.NavDrawerActivity; public class TagListFragment extends ListFragment { private static final String TAG = "TagListFragment"; @@ -36,27 +35,25 @@ public class TagListFragment extends ListFragment { @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); - if (!MenuItemUtils.isActivityDrawerOpen((NavDrawerActivity) getActivity())) { - final SearchView sv = new SearchView(getActivity()); - MenuItemUtils.addSearchItem(menu, sv); - sv.setQueryHint(getString(R.string.gpodnet_search_hint)); - sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { - @Override - public boolean onQueryTextSubmit(String s) { - Activity activity = getActivity(); - if (activity != null) { - sv.clearFocus(); - ((MainActivity) activity).loadChildFragment(SearchListFragment.newInstance(s)); - } - return true; + final SearchView sv = new SearchView(getActivity()); + MenuItemUtils.addSearchItem(menu, sv); + sv.setQueryHint(getString(R.string.gpodnet_search_hint)); + sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String s) { + Activity activity = getActivity(); + if (activity != null) { + sv.clearFocus(); + ((MainActivity) activity).loadChildFragment(SearchListFragment.newInstance(s)); } + return true; + } - @Override - public boolean onQueryTextChange(String s) { - return false; - } - }); - } + @Override + public boolean onQueryTextChange(String s) { + return false; + } + }); } @Override