I am using the / stateLoss evasion add when using DialogFragment. To avoid invalid layoffs, I redefine the method dismiss:
@Override
public void dismiss() {
if (this.isVisible()) {
super.dismiss();
}
}
But isVisible()there is false, even if the dialogue is really visible. This is what isVisible()its documentation says :
Returns true if the fragment is currently displayed to the user. This means that: (1) was added, (2) has a view attached to the window, and (3) is not hidden.
So, if I changed the method to:
@Override
public void dismiss() {
if (this.isAdded() && !this.isDetached() && !this.isHidden()) {
super.dismiss();
}
}
then it works fine. Is this expected behavior?
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");
source
share