Fixed black padding when returning from pip
onConfigurationChanged returned slightly wrong size
This commit is contained in:
parent
fa93fbc16d
commit
629ad7e850
|
@ -17,9 +17,11 @@ import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
@ -56,6 +58,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
private LinearLayout videoOverlay;
|
private LinearLayout videoOverlay;
|
||||||
private AspectRatioVideoView videoview;
|
private AspectRatioVideoView videoview;
|
||||||
private ProgressBar progressIndicator;
|
private ProgressBar progressIndicator;
|
||||||
|
private FrameLayout videoframe;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void chooseTheme() {
|
protected void chooseTheme() {
|
||||||
|
@ -142,9 +145,10 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
controls = (LinearLayout) findViewById(R.id.controls);
|
controls = (LinearLayout) findViewById(R.id.controls);
|
||||||
videoOverlay = (LinearLayout) findViewById(R.id.overlay);
|
videoOverlay = (LinearLayout) findViewById(R.id.overlay);
|
||||||
videoview = (AspectRatioVideoView) findViewById(R.id.videoview);
|
videoview = (AspectRatioVideoView) findViewById(R.id.videoview);
|
||||||
|
videoframe = (FrameLayout) findViewById(R.id.videoframe);
|
||||||
progressIndicator = (ProgressBar) findViewById(R.id.progressIndicator);
|
progressIndicator = (ProgressBar) findViewById(R.id.progressIndicator);
|
||||||
videoview.getHolder().addCallback(surfaceHolderCallback);
|
videoview.getHolder().addCallback(surfaceHolderCallback);
|
||||||
findViewById(R.id.videoframe).setOnTouchListener(onVideoviewTouched);
|
videoframe.setOnTouchListener(onVideoviewTouched);
|
||||||
videoOverlay.setOnTouchListener((view, motionEvent) -> true); // To suppress touches directly below the slider
|
videoOverlay.setOnTouchListener((view, motionEvent) -> true); // To suppress touches directly below the slider
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 16) {
|
if (Build.VERSION.SDK_INT >= 16) {
|
||||||
|
@ -155,6 +159,9 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
setupVideoControlsToggler();
|
setupVideoControlsToggler();
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
|
||||||
|
videoframe.getViewTreeObserver().addOnGlobalLayoutListener(() ->
|
||||||
|
videoview.setAvailableSize(videoframe.getWidth(), videoframe.getHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -388,11 +395,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
|
videoframe.requestLayout();
|
||||||
DisplayMetrics dm = getResources().getDisplayMetrics();
|
|
||||||
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, newConfig.screenWidthDp, dm);
|
|
||||||
float py = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, newConfig.screenHeightDp, dm);
|
|
||||||
videoview.setAvailableSize(px, py);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class VideoControlsHider extends Handler {
|
private static class VideoControlsHider extends Handler {
|
||||||
|
|
|
@ -109,6 +109,7 @@ public class AspectRatioVideoView extends VideoView {
|
||||||
public void setAvailableSize(float width, float height) {
|
public void setAvailableSize(float width, float height) {
|
||||||
mAvailableWidth = width;
|
mAvailableWidth = width;
|
||||||
mAvailableHeight = height;
|
mAvailableHeight = height;
|
||||||
|
requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue