Modify to avoid DialogFragment crash at resume/pause timing