Fix dispatching of events when EventDispatcher is not initialized
Summary: This diff fixes a NPE that can occur when we force the dispatching of events when the EventDispatcher is not initized. The fix consists on avoid posting the frame callback, if the internals of EventDispatcher are not initialized yet (same behavior used by the dispatchEvent method) Reviewed By: fkgozali Differential Revision: D13549147 fbshipit-source-id: ef3baeb536e8772fbd83024352a37af01c21d589
This commit is contained in:
parent
acc2ed2488
commit
5957c8b370
|
@ -125,6 +125,14 @@ public class EventDispatcher implements LifecycleEventListener {
|
|||
event.getEventName(),
|
||||
event.getUniqueID());
|
||||
}
|
||||
maybePostFrameCallbackFromNonUI();
|
||||
}
|
||||
|
||||
public void dispatchAllEvents() {
|
||||
maybePostFrameCallbackFromNonUI();
|
||||
}
|
||||
|
||||
private void maybePostFrameCallbackFromNonUI() {
|
||||
if (mReactEventEmitter != null) {
|
||||
// If the host activity is paused, the frame callback may not be currently
|
||||
// posted. Ensure that it is so that this event gets delivered promptly.
|
||||
|
@ -137,10 +145,6 @@ public class EventDispatcher implements LifecycleEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void dispatchAllEvents() {
|
||||
mCurrentFrameCallback.maybePostFromNonUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a listener to this EventDispatcher.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue