[Android] Update VLC menu once Activity is fully started

Geoffrey Métais git at videolan.org
Mon Jul 2 17:47:03 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul  2 16:05:01 2018 +0200| [d363cd422bb7f845158ca7f6598d87c8ebdbd21a] | committer: Geoffrey Métais

Update VLC menu once Activity is fully started

Avoid IllegalStateException

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

 .../src/org/videolan/vlc/gui/MainActivity.java     | 25 ++++++++++++----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 8532e80d8..965520051 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -99,12 +99,12 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
         mNavigator = new Navigator(this, mSettings, mExtensionManagerService, savedInstanceState);
         if (savedInstanceState == null) {
             if (getIntent().getBooleanExtra(Constants.EXTRA_UPGRADE, false)) {
-            /*
-             * The sliding menu is automatically opened when the user closes
-             * the info dialog. If (for any reason) the dialog is not shown,
-             * open the menu after a short delay.
-             */
-            mActivityHandler.postDelayed(new Runnable() {
+                /*
+                 * The sliding menu is automatically opened when the user closes
+                 * the info dialog. If (for any reason) the dialog is not shown,
+                 * open the menu after a short delay.
+                 */
+                mActivityHandler.postDelayed(new Runnable() {
                     @Override
                     public void run() {
                         mDrawerLayout.openDrawer(mNavigationView);
@@ -184,11 +184,14 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
         mNavigationView.setNavigationItemSelectedListener(mNavigator);
         final boolean wasVisible = mNavigationView.getMenu().findItem(R.id.nav_video).isVisible();
         final boolean scan = mSettings.getInt(Constants.KEY_MEDIALIBRARY_SCAN, Constants.ML_SCAN_OFF) == Constants.ML_SCAN_ON;
-        if (wasVisible != scan) {
-            mNavigationView.getMenu().findItem(R.id.nav_audio).setVisible(scan);
-            mNavigationView.getMenu().findItem(R.id.nav_video).setVisible(scan);
-            if (scan) getNavigator().showFragment(R.id.nav_video);
-        }
+        if (wasVisible != scan) mActivityHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                mNavigationView.getMenu().findItem(R.id.nav_audio).setVisible(scan);
+                mNavigationView.getMenu().findItem(R.id.nav_video).setVisible(scan);
+                if (scan) getNavigator().showFragment(R.id.nav_video);
+            }
+        });
     }
 
     public boolean isExtensionServiceBinded() {



More information about the Android mailing list