eltos / SimpleDialogFragments

An Android library to create dialogs with ease and handle user interaction reliably, using fragments and material design.
Apache License 2.0
119 stars 17 forks source link

Crash after phone wake up if SimpleFormDialog was stay in foreground. #33

Closed isabsent closed 6 years ago

isabsent commented 6 years ago

There is a problem with SimpleFormDialog if it was in foreground when device going to sleep. When it wake up application crashes because of getDialog() is null in the following code:

@Override
protected void onDialogShown() {
    // resize dialog when keyboard is shown to prevent fields from hiding behind the keyboard
    if (getDialog().getWindow() != null) {
        getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    }

    setPositiveButtonEnabled(posButtonEnabled());
    requestFocus(0);
}

If I add null check to it - if (getDialog() != null && getDialog().getWindow() != null) - the crash disappears.