[Android] ICS: show overlay when the system bar appears.

Sébastien Toque git at videolan.org
Wed Jul 18 01:27:03 CEST 2012


android | branch: master | Sébastien Toque <xilasz at gmail.com> | Wed Jul 18 01:05:02 2012 +0200| [642a06cc05af8fa0446185c2ec70e62a7073810a] | committer: Sébastien Toque

ICS: show overlay when the system bar appears.

It is necessary to check if the visibility has changed, because the listener can be called several times in a row with the same visibility.

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=642a06cc05af8fa0446185c2ec70e62a7073810a
---

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java    |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 14f8327..5eb716e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -107,6 +107,7 @@ public class VideoPlayerActivity extends Activity {
     private static final int HIDE_NAV = 5;
     private boolean mDragging;
     private boolean mShowing;
+    private int mUiVisibility = -1;
     private SeekBar mSeekbar;
     private TextView mTitle;
     private TextView mSysTime;
@@ -149,11 +150,12 @@ public class VideoPlayerActivity extends Activity {
         if(Util.isICSOrLater())
             getWindow().getDecorView().findViewById(android.R.id.content).setOnSystemUiVisibilityChangeListener(
                     new OnSystemUiVisibilityChangeListener() {
-                        @Override
-                        @TargetApi(14)
                         public void onSystemUiVisibilityChange(int visibility) {
-                            if(visibility == View.SYSTEM_UI_FLAG_VISIBLE && Util.isICSOrLater())
+                            if (visibility == View.SYSTEM_UI_FLAG_VISIBLE && !mShowing && visibility != mUiVisibility) {
+                                showOverlay();
                                 mHandler.sendMessageDelayed(mHandler.obtainMessage(HIDE_NAV), OVERLAY_TIMEOUT);
+                            }
+                            mUiVisibility = visibility;
                         }
                     }
             );



More information about the Android mailing list