[Android] [PATCH 3/4] VideoPlayer: change SurfaceLayout via OnLayoutChangeListener
Thomas Guillem
thomas at gllm.fr
Fri Nov 21 16:36:11 CET 2014
---
.../vlc/gui/video/VideoPlayerActivity.java | 24 +++++++++++++++-------
1 file changed, 17 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 abcecec..85bff16 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,15 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
private boolean mHasMenu = false;
private boolean mIsNavMenu = false;
+ private OnLayoutChangeListener 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);
+ }
+ };
+
@Override
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
protected void onCreate(Bundle savedInstanceState) {
@@ -302,7 +312,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 +537,12 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
AudioServiceController.getInstance().unbindAudioService(this);
}
+ @Override
+ protected void onStart() {
+ mSurfaceFrame.addOnLayoutChangeListener(mOnLayoutChangeListener);
+ super.onStart();
+ }
+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
protected void onStop() {
@@ -540,6 +555,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
mPresentation = null;
}
restoreBrightness();
+ mSurfaceFrame.removeOnLayoutChangeListener(mOnLayoutChangeListener);
}
@TargetApi(android.os.Build.VERSION_CODES.FROYO)
@@ -853,12 +869,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
More information about the Android
mailing list