Permalink
Browse files

check if listener is still in the set before calling onHostResume

Reviewed By: achen1

Differential Revision: D6341419

fbshipit-source-id: e49188803bbf3641bad6a9cc8c497d453798bbce
  • Loading branch information...
Alexander Komissarov authored and facebook-github-bot committed Nov 17, 2017
1 parent 231c7a0 commit ad89ea7b5046c2cf9ca1cba88c387eb1db8dc042
Showing with 14 additions and 10 deletions.
  1. +14 −10 ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java
@@ -141,16 +141,20 @@ public void addLifecycleEventListener(final LifecycleEventListener listener) {
case BEFORE_RESUME:
break;
case RESUMED:
runOnUiQueueThread(new Runnable() {
@Override
public void run() {
try {
listener.onHostResume();
} catch (RuntimeException e) {
handleException(e);
}
}
});
runOnUiQueueThread(
new Runnable() {
@Override
public void run() {
if (!mLifecycleEventListeners.contains(listener)) {
return;
}
try {
listener.onHostResume();
} catch (RuntimeException e) {
handleException(e);
}
}
});
break;
default:
throw new RuntimeException("Unhandled lifecycle state.");

0 comments on commit ad89ea7

Please sign in to comment.