Fix height bug

pull/605/head
jhengazuki 5 months ago
parent 3e2e7b4bf0
commit 102324ea6d
  1. 7
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java

@ -404,6 +404,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
mAnimator = new ValueAnimator();
mAnimator.setInterpolator(new DecelerateInterpolator());
mAnimator.addUpdateListener(animation -> {
if (isLand() || isFullscreen() || isInPictureInPictureMode()) return;
mFrameParams.height = (int) animation.getAnimatedValue();
mBinding.video.setLayoutParams(mFrameParams);
});
@ -1198,7 +1199,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
mClock.setCallback(this);
break;
case PlayerEvent.SIZE:
mBinding.video.post(this::changeHeight);
changeHeight();
checkOrientation();
break;
}
@ -1223,10 +1224,10 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
int videoWidth = mPlayers.getVideoWidth();
int videoHeight = mPlayers.getVideoHeight();
if (videoWidth == 0 || videoHeight == 0) return;
int viewWidth = ResUtil.getScreenWidth();
int minHeight = ResUtil.dp2px(150);
int maxHeight = ResUtil.getScreenHeight() / 2;
int parentWidth = ((View) mBinding.video.getParent()).getWidth();
int calculated = (int) (parentWidth * ((float) videoHeight / videoWidth));
int calculated = (int) (viewWidth * ((float) videoHeight / videoWidth));
int finalHeight = Math.max(minHeight, Math.min(maxHeight, calculated));
if (finalHeight == mBinding.video.getHeight()) return;
if (mAnimator.isRunning()) mAnimator.cancel();

Loading…
Cancel
Save