mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Make sure that AccessibilityInfoModule is subscribed to LifecycleEventListener events, and unsubscribes in onCatalystInstanceDestroy
Summary: If modules are *not* eagerly init'd and expect lifecycle events, make sure (1) onHostResume is called immediately it it's currently active and (2) that listeners are removed in onCatalystInstanceDestroy. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26859159 fbshipit-source-id: 8e47cedd4b218a47b33d1209f3ede2fd1531015d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
014c6f9636
commit
66febd1e34
+6
-2
@@ -157,7 +157,7 @@ public class AccessibilityInfoModule extends NativeAccessibilityInfoSpec
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
getReactApplicationContext().addLifecycleEventListener(this);
|
||||
getReactApplicationContext().addLifecycleEventListenerAndCheckState(this);
|
||||
updateAndSendTouchExplorationChangeEvent(mAccessibilityManager.isTouchExplorationEnabled());
|
||||
updateAndSendReduceMotionChangeEvent();
|
||||
}
|
||||
@@ -165,7 +165,11 @@ public class AccessibilityInfoModule extends NativeAccessibilityInfoSpec
|
||||
@Override
|
||||
public void onCatalystInstanceDestroy() {
|
||||
super.onCatalystInstanceDestroy();
|
||||
getReactApplicationContext().removeLifecycleEventListener(this);
|
||||
|
||||
ReactApplicationContext applicationContext = getReactApplicationContextIfActiveOrWarn();
|
||||
if (applicationContext != null) {
|
||||
applicationContext.removeLifecycleEventListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user