Remove life cycle observers

pull/206/head
M66B 3 years ago
parent bffe51d71c
commit e06c938b0d

@ -510,6 +510,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
public void onDestroyed() {
Log.d("Removing back listener=" + listener);
keyPressedListeners.remove(listener);
owner.getLifecycle().removeObserver(this);
}
});
}

@ -573,6 +573,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
public void onDestroyed() {
Log.d(AdapterAccount.this + " parent destroyed");
AdapterAccount.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -286,6 +286,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
public void onDestroyed() {
Log.d(AdapterAnswer.this + " parent destroyed");
AdapterAnswer.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});

@ -342,6 +342,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
public void onDestroyed() {
Log.d(AdapterAttachment.this + " parent destroyed");
AdapterAttachment.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -366,6 +366,7 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
public void onDestroyed() {
Log.d(AdapterContact.this + " parent destroyed");
AdapterContact.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -1152,6 +1152,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
public void onDestroyed() {
Log.d(AdapterFolder.this + " parent destroyed");
AdapterFolder.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -359,6 +359,7 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
public void onDestroyed() {
Log.d(AdapterIdentity.this + " parent destroyed");
AdapterIdentity.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -182,6 +182,7 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
public void onDestroyed() {
Log.d(AdapterImage.this + " parent destroyed");
AdapterImage.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -138,6 +138,7 @@ public class AdapterLog extends RecyclerView.Adapter<AdapterLog.ViewHolder> {
public void onDestroyed() {
Log.d(AdapterLog.this + " parent destroyed");
AdapterLog.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -132,6 +132,7 @@ public class AdapterNavSearch extends RecyclerView.Adapter<AdapterNavSearch.View
public void onDestroyed() {
Log.d(AdapterNavSearch.this + " parent destroyed");
AdapterNavSearch.this.manager = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -264,6 +264,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
public void onDestroyed() {
Log.d(AdapterOperation.this + " parent destroyed");
AdapterOperation.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -81,6 +81,7 @@ public class AdapterOrder extends RecyclerView.Adapter<AdapterOrder.ViewHolder>
public void onDestroyed() {
Log.d(AdapterOrder.this + " parent destroyed");
AdapterOrder.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -416,6 +416,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
public void onDestroyed() {
Log.d(AdapterRule.this + " parent destroyed");
AdapterRule.this.parentFragment = null;
owner.getLifecycle().removeObserver(this);
}
});
}

@ -88,6 +88,7 @@ public class AdapterRuleMatch extends RecyclerView.Adapter<AdapterRuleMatch.View
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() {
Log.d(AdapterRuleMatch.this + " parent destroyed");
owner.getLifecycle().removeObserver(this);
}
});
}

@ -1915,6 +1915,7 @@ public class Helper {
public void onDestroy() {
Log.i("Authenticate destroyed");
ApplicationEx.getMainHandler().post(cancelPrompt);
owner.getLifecycle().removeObserver(this);
}
});
@ -2083,6 +2084,11 @@ public class Helper {
else
intf.onSelected(selected);
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroy() {
owner.getLifecycle().removeObserver(this);
}
});
}
}

@ -42,13 +42,20 @@ import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.OnLifecycleEvent;
public class PopupMenuLifecycle extends PopupMenu implements LifecycleObserver {
public class PopupMenuLifecycle extends PopupMenu {
public PopupMenuLifecycle(@NonNull Context context, LifecycleOwner owner, @NonNull View anchor) {
super(new ContextThemeWrapper(context, R.style.popupMenuStyle), anchor);
Log.i("Instantiate " + this);
owner.getLifecycle().addObserver(this);
owner.getLifecycle().addObserver(new LifecycleObserver() {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroy() {
Log.i("Destroy " + this);
PopupMenuLifecycle.this.dismiss();
owner.getLifecycle().removeObserver(this);
}
});
}
public void insertIcons(Context context) {
@ -88,12 +95,6 @@ public class PopupMenuLifecycle extends PopupMenu implements LifecycleObserver {
});
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroy() {
Log.i("Destroy " + this);
this.dismiss();
}
static void insertIcons(Context context, Menu menu) {
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);

@ -223,6 +223,8 @@ public class ViewModelMessages extends ViewModel {
}
dump();
owner.getLifecycle().removeObserver(this);
}
});
@ -580,6 +582,7 @@ public class ViewModelMessages extends ViewModel {
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
public void onDestroyed() {
boundary.destroy(state);
owner.getLifecycle().removeObserver(this);
}
});
}

Loading…
Cancel
Save