Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android-AlertView与作者另外一个SVProgressHUD这个库一起使用报错 #33

Open
FlogFly opened this issue Oct 13, 2017 · 1 comment

Comments

@FlogFly
Copy link

FlogFly commented Oct 13, 2017

比如先弹出一个alertView,然后点击弹框上的按钮,然后显示一个SVProgress的提示框,就出现报错。我看了下,二个库的写法都是把布局加到了DecorView .然后消失的时候移除,中间出现问题:

比如点击了弹框的确认按钮,这时候执行:

@Override
    public void onItemClick(Object o, int position) {
        if (position == 0) {
            svProgressHUD.showErrorWithStatus("hahah");
        }
    }

这个时候执行完onItemClick的时候,就会把AlertView这个View从decorView中移除,但是这时候,如果启动了svProgressHUD弹框,这时候又会去往decorView中加View,就会报错。

java.lang.NullPointerException: Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference

所以如果把SVProgressHUD的弹框的显示放在onDismiss中就不会有问题:

@Override
    public void onDismiss(Object o) {
         svProgressHUD.showErrorWithStatus("hahah");
    }

因为代码是先remove后再执行onDismiss,这时候去执行就SVProgress的话,decorView去add就不会报错了,没有冲突,因为这时候Alertview的remove动作已经结束:

public void dismissImmediately() {
        decorView.removeView(rootView);
        isShowing = false;
        if(onDismissListener != null){
            onDismissListener.onDismiss(this);
        }

    }
@FlogFly
Copy link
Author

FlogFly commented Oct 13, 2017

说反了,是SVProgress在往DecorView添加东西的时候,AlertView正好要执行dismiss,要去DecorView执行remove,然后就出错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant