Dismiss popup on detaching anchor

This commit is contained in:
M66B
2019-09-21 16:15:55 +02:00
parent 898f7777ef
commit 68d421a421
2 changed files with 14 additions and 2 deletions

View File

@@ -36,6 +36,18 @@ public class PopupMenuLifecycle extends PopupMenu implements LifecycleObserver {
super(context, anchor);
this.owner = owner;
Log.i("Instantiate " + this);
anchor.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
// Do nothing
}
@Override
public void onViewDetachedFromWindow(View v) {
PopupMenuLifecycle.this.dismiss();
}
});
}
@Override