[Android] Workaround menu item expand cb not called

Geoffrey Métais git at videolan.org
Fri Mar 22 16:20:23 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar 22 16:05:02 2019 +0100| [5fe6f2a30c893622f2c310a451f25fe8c3f59d00] | committer: Geoffrey Métais

Workaround menu item expand cb not called

onMenuItemActionExpand is never called, despite onMenuItemActionCollapse
is.
For zorkaroundm we manually change search visibility

> https://code.videolan.org/videolan/vlc-android/commit/5fe6f2a30c893622f2c310a451f25fe8c3f59d00
---

 .../src/org/videolan/vlc/gui/ContentActivity.java    | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java b/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java
index 3be7cc937..6bbf639dc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/ContentActivity.java
@@ -96,20 +96,21 @@ public class ContentActivity extends AudioPlayerContainerActivity implements Sea
     @Override
     public boolean onCreateOptionsMenu(final Menu menu) {
         if (AndroidDevices.isAndroidTv) return false;
-        if (getSupportFragmentManager().findFragmentById(R.id.fragment_placeholder) instanceof AboutFragment)
-            return true;
+        final Fragment current = getCurrentFragment();
+        if (current instanceof AboutFragment)
+            return false;
         getMenuInflater().inflate(R.menu.activity_option, menu);
-        if (getCurrentFragment() instanceof ExtensionBrowser){
+        super.onCreateOptionsMenu(menu);
+        if (current instanceof ExtensionBrowser){
             menu.findItem(R.id.ml_menu_last_playlist).setVisible(false);
             menu.findItem(R.id.ml_menu_sortby).setVisible(false);
         }
-        if (getCurrentFragment() instanceof Filterable) {
-            final Filterable filterable = (Filterable) getCurrentFragment();
+        if (current instanceof Filterable) {
+            final Filterable filterable = (Filterable) current;
             final MenuItem searchItem = menu.findItem(R.id.ml_menu_filter);
             mSearchView = (SearchView) searchItem.getActionView();
             mSearchView.setQueryHint(getString(R.string.search_list_hint));
             mSearchView.setOnQueryTextListener(this);
-            searchItem.setOnActionExpandListener(this);
             final String query = filterable.getFilterQuery();
             if (!TextUtils.isEmpty(query)) {
                 mActivityHandler.post(new Runnable() {
@@ -122,16 +123,15 @@ public class ContentActivity extends AudioPlayerContainerActivity implements Sea
                     }
                 });
             }
+            searchItem.setOnActionExpandListener(this);
         } else menu.findItem(R.id.ml_menu_filter).setVisible(false);
         menu.findItem(R.id.ml_menu_renderers).setVisible(showRenderers && Settings.INSTANCE.getInstance(this).getBoolean("enable_casting", true));
         menu.findItem(R.id.ml_menu_renderers).setIcon(!PlaybackService.Companion.hasRenderer() ? R.drawable.ic_am_renderer_normal_w : R.drawable.ic_am_renderer_on_w);
-        return super.onCreateOptionsMenu(menu);
+        return true;
     }
 
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
-
-        // Handle item selection
         switch (item.getItemId()) {
             case R.id.ml_menu_search:
                 startActivity(new Intent(Intent.ACTION_SEARCH, null, this, SearchActivity.class));
@@ -146,6 +146,8 @@ public class ContentActivity extends AudioPlayerContainerActivity implements Sea
                 } else if (getSupportFragmentManager().findFragmentByTag("renderers") == null)
                     new RenderersDialog().show(getSupportFragmentManager(), "renderers");
                 return true;
+            case R.id.ml_menu_filter:
+                if (!item.isActionViewExpanded()) setSearchVisibility(true);
             default:
                 return super.onOptionsItemSelected(item);
         }



More information about the Android mailing list