Skip to content

Commit

Permalink
check if listener is still in the set before calling onHostResume
Browse files Browse the repository at this point in the history
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 ad89ea7
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit ad89ea7

Please sign in to comment.