[Android] ViewStub for video player tips

Geoffrey Métais git at videolan.org
Mon Jan 9 16:38:48 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan  9 15:12:18 2017 +0100| [28c99858493bf78d324ce80cceb43bef3f3e7f4c] | committer: Geoffrey Métais

ViewStub for video player tips

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

 vlc-android/res/layout/player.xml                         |  4 ++--
 vlc-android/res/layout/player_tips.xml                    |  1 +
 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java   | 15 +++++++--------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/vlc-android/res/layout/player.xml b/vlc-android/res/layout/player.xml
index 8525061..64823d5 100644
--- a/vlc-android/res/layout/player.xml
+++ b/vlc-android/res/layout/player.xml
@@ -42,11 +42,11 @@
         android:layout_height="match_parent"
         android:fitsSystemWindows="true" >
 
-        <include
+        <android.support.v7.widget.ViewStubCompat
             android:id="@+id/player_overlay_tips"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            layout="@layout/player_tips" />
+            android:layout="@layout/player_tips" />
 
         <ImageView
             android:id="@+id/player_overlay_loading"
diff --git a/vlc-android/res/layout/player_tips.xml b/vlc-android/res/layout/player_tips.xml
index 2233d5d..566dc42 100644
--- a/vlc-android/res/layout/player_tips.xml
+++ b/vlc-android/res/layout/player_tips.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/overlay_tips_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@color/grey900transparent"
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 4a06867..3ede784 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -61,6 +61,7 @@ import android.support.v7.app.AppCompatActivity;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.PopupMenu;
 import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.ViewStubCompat;
 import android.support.v7.widget.helper.ItemTouchHelper;
 import android.text.TextUtils;
 import android.text.format.DateFormat;
@@ -497,12 +498,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         if (mPresentation == null) {
             // Orientation
             // Tips
-            mOverlayTips = findViewById(R.id.player_overlay_tips);
-            if(BuildConfig.DEBUG || VLCApplication.showTvUi() || mSettings.getBoolean(PREF_TIPS_SHOWN, false))
-                mOverlayTips.setVisibility(View.GONE);
-            else {
-                mOverlayTips.bringToFront();
-                mOverlayTips.invalidate();
+            if (!BuildConfig.DEBUG && !VLCApplication.showTvUi() && !mSettings.getBoolean(PREF_TIPS_SHOWN, false)) {
+                ((ViewStubCompat) findViewById(R.id.player_overlay_tips)).inflate();
+                mOverlayTips = findViewById(R.id.overlay_tips_layout);
             }
 
             //Set margins for TV overscan
@@ -525,6 +523,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         getWindowManager().getDefaultDisplay().getMetrics(mScreen);
         mSurfaceYDisplayRange = Math.min(mScreen.widthPixels, mScreen.heightPixels);
         mSurfaceXDisplayRange = Math.max(mScreen.widthPixels, mScreen.heightPixels);
+
     }
 
     @Override
@@ -3443,11 +3442,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     }
 
     public void onClickOverlayTips(View v) {
-        mOverlayTips.setVisibility(View.GONE);
+        UiTools.setViewVisibility(mOverlayTips, View.GONE);
     }
 
     public void onClickDismissTips(View v) {
-        mOverlayTips.setVisibility(View.GONE);
+        UiTools.setViewVisibility(mOverlayTips, View.GONE);
         Editor editor = mSettings.edit();
         editor.putBoolean(PREF_TIPS_SHOWN, true);
         editor.apply();



More information about the Android mailing list