[Android] Fix menudrawer being removed from view hierarchy

Geoffrey Métais git at videolan.org
Thu Oct 30 15:30:39 CET 2014


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Oct 30 10:33:58 2014 +0100| [74fcb6280778f0bdcc55ac6f59d36393fa9f40c9] | committer: Geoffrey Métais

Fix menudrawer being removed from view hierarchy

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=74fcb6280778f0bdcc55ac6f59d36393fa9f40c9
---

 vlc-android/res/layout/audio_player_tips.xml       |    1 +
 vlc-android/res/layout/audio_playlist_tips.xml     |    1 +
 .../src/org/videolan/vlc/gui/MainActivity.java     |   20 +++++++-------------
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/vlc-android/res/layout/audio_player_tips.xml b/vlc-android/res/layout/audio_player_tips.xml
index 850f67a..148931f 100644
--- a/vlc-android/res/layout/audio_player_tips.xml
+++ b/vlc-android/res/layout/audio_player_tips.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/audio_tips"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@color/transparent_white"
diff --git a/vlc-android/res/layout/audio_playlist_tips.xml b/vlc-android/res/layout/audio_playlist_tips.xml
index c3396d5..7694c12 100644
--- a/vlc-android/res/layout/audio_playlist_tips.xml
+++ b/vlc-android/res/layout/audio_playlist_tips.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/audio_tips"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@color/transparent_white"
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index c8d830d..d3fd535 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -72,11 +72,11 @@ import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
 import android.support.v4.view.GravityCompat;
 import android.support.v4.widget.DrawerLayout;
-import android.support.v4.widget.DrawerLayout.LayoutParams;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.ActionBarActivity;
 import android.text.InputType;
 import android.util.Log;
+import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -89,9 +89,7 @@ import android.widget.AdapterView.OnItemClickListener;
 import android.widget.EditText;
 import android.widget.ListView;
 import android.widget.ProgressBar;
-import android.widget.RelativeLayout;
 import android.widget.TextView;
-import android.view.KeyEvent;
 
 public class MainActivity extends ActionBarActivity {
     public final static String TAG = "VLC/MainActivity";
@@ -990,14 +988,6 @@ public class MainActivity extends ActionBarActivity {
                 mRootContainer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
                 removeTipViewIfDisplayed();
                 mAudioPlayer.showAudioPlayerTips();
-                /*
-                 * TODO proper resolution of this bug
-                 * Drawer listview disappears when audio player is displayed
-                 * Here we restore it, this is just a workaround...
-                 */
-                if (findViewById(R.id.sidelist) == null){
-                	mRootContainer.addView(mListView);
-                }
             }
 
             @Override
@@ -1053,7 +1043,11 @@ public class MainActivity extends ActionBarActivity {
      * Remove the current tip view if there is one displayed.
      */
     public void removeTipViewIfDisplayed() {
-        if (mRootContainer.getChildCount() > 1)
-            mRootContainer.removeViewAt(1);
+        if (mRootContainer.getChildCount() > 2){
+            for (int i = 0 ; i< mRootContainer.getChildCount() ; ++i){
+            if (mRootContainer.getChildAt(i).getId() == R.id.audio_tips)
+                mRootContainer.removeViewAt(i);
+            }
+        }
     }
 }



More information about the Android mailing list