Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: propagating lifecycle events to AndroidScreenLifecycleOwner #230

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

DevSrSouza
Copy link
Collaborator

@DevSrSouza DevSrSouza commented Oct 16, 2023

fixes #225
fixes #186
fixes #173

if (activity != null && activity is LifecycleOwner) {
private fun registerLifecycleListenerForSaveState(outState: Bundle) {
val lifecycleOwner = getParentLifecycleOwnerOrActivityOrNull()
if (lifecycleOwner != null) {
val observer = object : DefaultLifecycleObserver {
override fun onStop(owner: LifecycleOwner) {
performSave(outState)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be moved to the proper lifecycle listener

* Returns a unregister callback
*/
private fun registerLifecycleListenerPropagation(): () -> Unit {
val lifecycleOwner = getParentLifecycleOwnerOrActivityOrNull()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing this instead of just using atomicParentLifecycleOwner?

@DevSrSouza
Copy link
Collaborator Author

Did some cleanup and some documentation @Syer10

@DevSrSouza DevSrSouza merged commit 6154083 into main Oct 17, 2023
1 check passed
@DevSrSouza DevSrSouza deleted the fix/lifecycle-events branch October 17, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants