Skip to content

Commit

Permalink
修复弹窗多个开启时关于StatusBar设置无效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
junixapp committed Aug 16, 2022
1 parent da8fdef commit 4cc7c21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public void onClick(View v) {
case R.id.btnShowConfirm: //带确认和取消按钮的弹窗
/*if(popupView==null)*/
popupView = new XPopup.Builder(getContext())
// .hasStatusBar(false)
.isDestroyOnDismiss(true)
// .isTouchThrough(true)
// .dismissOnBackPressed(false)
Expand Down Expand Up @@ -306,7 +305,7 @@ public void onSelect(int position, String text) {
popupView = new ZhihuCommentPopup(getContext());
new XPopup.Builder(getContext())
.moveUpToKeyboard(false) //如果不加这个,评论弹窗会移动到软键盘上面
.isViewMode(true)
// .isViewMode(true)
// .enableDrag(false)
.isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
// .isThreeDrag(true) //是否开启三阶拖拽,如果设置enableDrag(false)则无效
Expand Down
11 changes: 6 additions & 5 deletions library/src/main/java/com/lxj/xpopup/core/FullScreenDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ protected void onCreate(Bundle savedInstanceState) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //尝试兼容部分手机上的状态栏空白问题
}

//隐藏导航栏
if (!contentView.popupInfo.hasNavigationBar) {
hideNavigationBar();
}

if(!contentView.popupInfo.isRequestFocus){//不获取焦点
int flag = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
if(contentView.popupInfo.isCoverSoftInput){
Expand Down Expand Up @@ -178,6 +173,10 @@ private String getResNameById(int id) {
}

public void setNavBarLightMode() {
//隐藏导航栏
if (!contentView.popupInfo.hasNavigationBar) {
hideNavigationBar();
}
int light = contentView.popupInfo.isLightNavigationBar == 0 ? XPopup.isLightNavigationBar : contentView.popupInfo.isLightNavigationBar;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && light!=0) {
View decorView = getWindow().getDecorView();
Expand All @@ -203,6 +202,8 @@ public FullScreenDialog setContent(BasePopupView view) {
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
setStatusBarLightMode();
setNavBarLightMode();
if(hasFocus && contentView!=null && contentView.hasMoveUp && contentView.popupStatus== PopupStatus.Show){
contentView.focusAndProcessBackPress();
KeyboardUtils.showSoftInput(contentView);
Expand Down

0 comments on commit 4cc7c21

Please sign in to comment.