Make sure that DialogModule is subscribed to LifecycleEventListener events

Summary:
I'm not sure what broke this, but in some cases, DialogModule doesn't get subscribed to LifecycleEventListener events.

This seems to fix it.

Changelog: [Internal]

Reviewed By: mdvacca, RSNara

Differential Revision: D26856016

fbshipit-source-id: 868baf102b85b202180adcbb8bb181dfe603188f
This commit is contained in:
Joshua Gross
2021-03-05 18:42:36 -08:00
committed by Facebook GitHub Bot
parent a206f4fc2e
commit aa305b34e3
@@ -156,7 +156,7 @@ public class DialogModule extends NativeDialogManagerAndroidSpec implements Life
@Override
public void initialize() {
getReactApplicationContext().addLifecycleEventListener(this);
getReactApplicationContext().addLifecycleEventListenerAndCheckState(this);
}
@Override
@@ -240,4 +240,14 @@ public class DialogModule extends NativeDialogManagerAndroidSpec implements Life
}
return new FragmentManagerHelper(((FragmentActivity) activity).getSupportFragmentManager());
}
@Override
public void onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy();
ReactApplicationContext applicationContext = getReactApplicationContextIfActiveOrWarn();
if (applicationContext != null) {
applicationContext.removeLifecycleEventListener(this);
}
}
}