[Android] [PATCH 3/4] VideoPlayer: change SurfaceLayout via OnLayoutChangeListener
Geoffrey Métais
geoffrey.metais at gmail.com
Tue Nov 25 16:43:34 CET 2014
LGTM
On Tue, Nov 25, 2014 at 4:20 PM, Thomas Guillem <thomas at gllm.fr> wrote:
> After Honeycomb only.
> ---
> .../vlc/gui/video/VideoPlayerActivity.java | 38
> ++++++++++++++++++----
> 1 file changed, 31 insertions(+), 7 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 faf4d10..cf11ef6 100644
> --- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
> +++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
> @@ -103,6 +103,7 @@ import android.view.SurfaceHolder.Callback;
> import android.view.SurfaceView;
> import android.view.View;
> import android.view.View.OnClickListener;
> +import android.view.View.OnLayoutChangeListener;
> import android.view.View.OnSystemUiVisibilityChangeListener;
> import android.view.ViewGroup;
> import android.view.ViewGroup.LayoutParams;
> @@ -264,6 +265,8 @@ public class VideoPlayerActivity extends
> ActionBarActivity implements IVideoPlay
> private boolean mHasMenu = false;
> private boolean mIsNavMenu = false;
>
> + private OnLayoutChangeListener mOnLayoutChangeListener;
> +
> @Override
> @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
> protected void onCreate(Bundle savedInstanceState) {
> @@ -302,7 +305,6 @@ public class VideoPlayerActivity extends
> ActionBarActivity implements IVideoPlay
> public void onSystemUiVisibilityChange(int
> visibility) {
> if (visibility == mUiVisibility)
> return;
> - setSurfaceLayout(mVideoWidth, mVideoHeight,
> mVideoVisibleWidth, mVideoVisibleHeight, mSarNum, mSarDen);
> if (visibility == View.SYSTEM_UI_FLAG_VISIBLE
> && !mShowing && !isFinishing()) {
> showOverlay();
> }
> @@ -528,6 +530,32 @@ public class VideoPlayerActivity extends
> ActionBarActivity implements IVideoPlay
> AudioServiceController.getInstance().unbindAudioService(this);
> }
>
> + @Override
> + public void onConfigurationChanged(Configuration newConfig) {
> + if (!LibVlcUtil.isHoneycombOrLater())
> + setSurfaceLayout(mVideoWidth, mVideoHeight,
> mVideoVisibleWidth, mVideoVisibleHeight, mSarNum, mSarDen);
> + super.onConfigurationChanged(newConfig);
> + }
> +
> + @Override
> + protected void onStart() {
> + if (LibVlcUtil.isHoneycombOrLater()) {
> + if (mOnLayoutChangeListener == null) {
> + mOnLayoutChangeListener = new
> View.OnLayoutChangeListener() {
> + @Override
> + public void onLayoutChange(View v, int left, int top,
> int right,
> + int bottom, int oldLeft, int oldTop, int
> oldRight, int oldBottom) {
> + if (left != oldLeft || top != oldTop || right !=
> oldRight || bottom != oldBottom)
> + setSurfaceLayout(mVideoWidth, mVideoHeight,
> mVideoVisibleWidth, mVideoVisibleHeight, mSarNum, mSarDen);
> + }
> + };
> + }
> +
> mSurfaceFrame.addOnLayoutChangeListener(mOnLayoutChangeListener);
> + }
> + setSurfaceLayout(mVideoWidth, mVideoHeight, mVideoVisibleWidth,
> mVideoVisibleHeight, mSarNum, mSarDen);
> + super.onStart();
> + }
> +
> @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
> @Override
> protected void onStop() {
> @@ -540,6 +568,8 @@ public class VideoPlayerActivity extends
> ActionBarActivity implements IVideoPlay
> mPresentation = null;
> }
> restoreBrightness();
> + if (LibVlcUtil.isHoneycombOrLater() && mOnLayoutChangeListener !=
> null)
> +
> mSurfaceFrame.removeOnLayoutChangeListener(mOnLayoutChangeListener);
> }
>
> @TargetApi(android.os.Build.VERSION_CODES.FROYO)
> @@ -853,12 +883,6 @@ public class VideoPlayerActivity extends
> ActionBarActivity implements IVideoPlay
> }
>
> @Override
> - public void onConfigurationChanged(Configuration newConfig) {
> - setSurfaceLayout(mVideoWidth, mVideoHeight, mVideoVisibleWidth,
> mVideoVisibleHeight, mSarNum, mSarDen);
> - super.onConfigurationChanged(newConfig);
> - }
> -
> - @Override
> public void setSurfaceLayout(int width, int height, int
> visible_width, int visible_height, int sar_num, int sar_den) {
> if (width * height == 0)
> return;
> --
> 2.1.1
>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20141125/656a7c64/attachment-0001.html>
More information about the Android
mailing list