mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-29 21:34:44 +02:00
Keep popup menu on update
This commit is contained in:
@@ -26,10 +26,13 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.LifecycleRegistry;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
// This class can be used as an externally controlled standalone or child life cycle owner
|
||||
|
||||
public class TwoStateOwner implements LifecycleOwner {
|
||||
private String name;
|
||||
private Object condition;
|
||||
private LifecycleRegistry registry;
|
||||
|
||||
// https://developer.android.com/topic/libraries/architecture/lifecycle#lc
|
||||
@@ -87,6 +90,13 @@ public class TwoStateOwner implements LifecycleOwner {
|
||||
create();
|
||||
}
|
||||
|
||||
void recreate(Object condition) {
|
||||
if (!Objects.equals(this.condition, condition)) {
|
||||
this.condition = condition;
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
Lifecycle.State state = registry.getCurrentState();
|
||||
if (!state.equals(Lifecycle.State.DESTROYED)) {
|
||||
|
||||
Reference in New Issue
Block a user