From c168997e338ff10e543adb9d8c30c63ecb403bb9 Mon Sep 17 00:00:00 2001 From: 857288218 <31814795+857288218@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:10:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A2=84=E8=A7=88=E9=A1=B5?= =?UTF-8?q?=E5=8D=95=E5=87=BB=E5=9B=BE=E7=89=87=E8=BF=9B=E5=85=A5=E5=85=A8?= =?UTF-8?q?=E5=B1=8F=E8=A7=82=E7=9C=8B=E6=A8=A1=E5=BC=8F=E5=90=8E=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E8=BF=94=E5=9B=9E=E4=B8=8A=E4=B8=80=E9=A1=B5=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=A0=8F=E6=B2=A1=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/PictureSelectorPreviewFragment.java | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/selector/src/main/java/com/luck/picture/lib/PictureSelectorPreviewFragment.java b/selector/src/main/java/com/luck/picture/lib/PictureSelectorPreviewFragment.java index 395a5b8e5..dcc6f03ce 100644 --- a/selector/src/main/java/com/luck/picture/lib/PictureSelectorPreviewFragment.java +++ b/selector/src/main/java/com/luck/picture/lib/PictureSelectorPreviewFragment.java @@ -162,6 +162,7 @@ public class PictureSelectorPreviewFragment extends PictureCommonFragment { protected List mAnimViews = new ArrayList<>(); private boolean isPause = false; + private boolean isEnterWindowFullScreen = false; public static PictureSelectorPreviewFragment newInstance() { PictureSelectorPreviewFragment fragment = new PictureSelectorPreviewFragment(); @@ -745,6 +746,7 @@ public void onBackPressed() { onBackCurrentFragment(); } } + exitWindowFullScreen(); } }); titleBar.setTitle((curPosition + 1) + "/" + totalNum); @@ -1294,6 +1296,7 @@ private void onKeyDownBackToMin() { } else { onBackCurrentFragment(); } + exitWindowFullScreen(); } } @@ -1325,20 +1328,10 @@ private void previewFullScreenMode() { @Override public void onAnimationEnd(Animator animation) { isAnimationStart = false; - if (SdkVersionUtils.isP() && isAdded()) { - Window window = requireActivity().getWindow(); - WindowManager.LayoutParams lp = window.getAttributes(); - if (isAnimInit) { - lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; - lp.layoutInDisplayCutoutMode = - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; - window.setAttributes(lp); - window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); - } else { - lp.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN); - window.setAttributes(lp); - window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); - } + if (isAnimInit) { + enterWindowFullScreen(); + } else { + exitWindowFullScreen(); } } }); @@ -1350,6 +1343,30 @@ public void onAnimationEnd(Animator animation) { } } + private void enterWindowFullScreen() { + if (SdkVersionUtils.isP() && isAdded() && !isEnterWindowFullScreen) { + isEnterWindowFullScreen = true; + Window window = requireActivity().getWindow(); + WindowManager.LayoutParams lp = window.getAttributes(); + lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; + lp.layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; + window.setAttributes(lp); + window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + } + } + + private void exitWindowFullScreen() { + if (SdkVersionUtils.isP() && isAdded() && isEnterWindowFullScreen) { + isEnterWindowFullScreen = false; + Window window = requireActivity().getWindow(); + WindowManager.LayoutParams lp = window.getAttributes(); + lp.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN); + window.setAttributes(lp); + window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); + } + } + /** * 全屏模式 */