[Android] Faster resizing

Geoffrey Métais git at videolan.org
Fri Apr 1 18:08:27 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Apr  1 17:54:44 2016 +0200| [940a207dd758ad705570077785e1d62d50dabef9] | committer: Geoffrey Métais

Faster resizing

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

 vlc-android/res/layout/video_popup.xml             |  7 +++----
 .../org/videolan/vlc/gui/video/PopupManager.java   | 23 +++++++++-------------
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/vlc-android/res/layout/video_popup.xml b/vlc-android/res/layout/video_popup.xml
index 9ed2d27..ba04a2f 100644
--- a/vlc-android/res/layout/video_popup.xml
+++ b/vlc-android/res/layout/video_popup.xml
@@ -30,11 +30,10 @@
 
     <ImageView
         android:id="@+id/video_play_pause"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_centerHorizontal="true"
-        android:layout_centerVertical="true"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
         android:layout_below="@id/popup_expand"
+        android:scaleType="center"
         android:src="@drawable/ic_popup_pause"
         android:visibility="gone" />
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
index 8b6e7c0..c34fdd1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.java
@@ -43,7 +43,6 @@ import android.view.MotionEvent;
 import android.view.ScaleGestureDetector;
 import android.view.SurfaceView;
 import android.view.View;
-import android.view.ViewGroup.LayoutParams;
 import android.view.WindowManager;
 import android.widget.ImageView;
 import android.widget.RelativeLayout;
@@ -227,7 +226,6 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
                 return;
             int sw = mRootView.getWidth();
             int sh = mRootView.getHeight();
-            vlcVout.setWindowSize(sw, sh);
 
             double dw = sw, dh = sh;
 
@@ -256,7 +254,10 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
             else
                 dw = dh * ar;
 
-            setViewSize(dw, dh);
+            width = (int) Math.floor(dw);
+            height = (int) Math.floor(dh);
+            vlcVout.setWindowSize(width, height);
+            setViewSize(width, height);
         }
 
         @Override public void onSurfacesCreated(IVLCVout vlcVout) {}
@@ -266,17 +267,11 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
         @Override public void onHardwareAccelerationError(IVLCVout vlcVout) {}
     };
 
-    private void setViewSize(double dw, double dh) {
-        LayoutParams lp = mSurfaceView.getLayoutParams();
-        lp.width = (int) Math.ceil(dw);
-        lp.height = (int) Math.ceil(dh);
-        mSurfaceView.setLayoutParams(lp);
-
-        lp = mRootView.getLayoutParams();
-        lp.width = (int) Math.floor(dw);
-        lp.height = (int) Math.floor(dh);
-        mRootView.setLayoutParams(lp);
-        mRootView.invalidate();
+    private void setViewSize(int width, int height) {
+        WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mRootView.getLayoutParams();
+        lp.width = width;
+        lp.height = height;
+        windowManager.updateViewLayout(mRootView, lp);
     }
 
     @Override



More information about the Android mailing list