I'm dealing with the dismiss/stateLoss hell when using DialogFragment. To avoid invalid dismisses I'm overriding the dismiss method:
@Override
public void dismiss() {
    if (this.isVisible()) {
        super.dismiss();
    }
}
But isVisible() is false even when the dialog is in fact visible. This is what the isVisible() method says in its documentation:
Return true if the fragment is currently visible to the user. This means it: (1) has been added, (2) has its view attached to the window, and (3) is not hidden.
So if I change the method to:
@Override
public void dismiss() {
    // This is almost the same as isVisible(), but the latter doesn't
    // work
    if (this.isAdded() && !this.isDetached() && !this.isHidden()) {
        super.dismiss();
    }
}
then it works perfectly. Is this expected behaviour?
Everything is executed after an HTTP request using Ion:
DialogFragment dialog = DialogFragment.newInstance(..., ...);
Ion.with(context, url)
.setCallback(new FutureCallback<JsonObject>() {
    @Override
    public void onCompleted(Exception e, JsonObject result) {
        dialog.dismiss()
    }
});
dialog.show(getFragmentManager(), "tag");