Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public class PictureSelectorPreviewFragment extends PictureCommonFragment {
protected List<View> mAnimViews = new ArrayList<>();

private boolean isPause = false;
private boolean isEnterWindowFullScreen = false;

public static PictureSelectorPreviewFragment newInstance() {
PictureSelectorPreviewFragment fragment = new PictureSelectorPreviewFragment();
Expand Down Expand Up @@ -745,6 +746,7 @@ public void onBackPressed() {
onBackCurrentFragment();
}
}
exitWindowFullScreen();
}
});
titleBar.setTitle((curPosition + 1) + "/" + totalNum);
Expand Down Expand Up @@ -1294,6 +1296,7 @@ private void onKeyDownBackToMin() {
} else {
onBackCurrentFragment();
}
exitWindowFullScreen();
}
}

Expand Down Expand Up @@ -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();
}
}
});
Expand All @@ -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);
}
}

/**
* 全屏模式
*/
Expand Down