check if listener is still in the set before calling onHostResume

Reviewed By: achen1

Differential Revision: D6341419

fbshipit-source-id: e49188803bbf3641bad6a9cc8c497d453798bbce
This commit is contained in:
Alexander Komissarov 2017-11-17 11:17:10 -08:00 committed by Facebook Github Bot
parent 231c7a0304
commit ad89ea7b50
1 changed files with 14 additions and 10 deletions

View File

@ -141,16 +141,20 @@ public class ReactContext extends ContextWrapper {
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.");