mirror of
https://github.com/status-im/react-native.git
synced 2025-02-21 13:48:13 +00:00
Introduce EventBeatManager and enable events
Summary: This diff introduces the concept of EventBeatManager, this is a class that acts as a proxy between the list of EventBeats registered in C++ and the Android side. Reviewed By: shergin Differential Revision: D10127857 fbshipit-source-id: a1956ca42d4c470fbc11cc9f30336a182fe7910c
This commit is contained in:
parent
5be0dff433
commit
9e7d918365
@ -1,37 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.fabric;
|
||||
|
||||
import com.facebook.react.bridge.JavaScriptContextHolder;
|
||||
import com.facebook.react.bridge.NativeMap;
|
||||
import com.facebook.react.bridge.UIManager;
|
||||
|
||||
public interface FabricBinding {
|
||||
|
||||
void installFabric(JavaScriptContextHolder jsContext, FabricBinder fabricBinder);
|
||||
// TODO: T31905686 change types of UIManager and EventBeatManager when moving to OSS
|
||||
void installFabric(
|
||||
JavaScriptContextHolder jsContext, FabricBinder fabricBinder, Object eventBeatManager);
|
||||
|
||||
void releaseEventTarget(long jsContextNativePointer, long eventTargetPointer);
|
||||
|
||||
void releaseEventHandler(long jsContextNativePointer, long eventHandlerPointer);
|
||||
|
||||
void dispatchEventToEmptyTarget(
|
||||
long jsContextNativePointer,
|
||||
long eventHandlerPointer,
|
||||
String type,
|
||||
NativeMap payload
|
||||
);
|
||||
long jsContextNativePointer, long eventHandlerPointer, String type, NativeMap payload);
|
||||
|
||||
void dispatchEventToTarget(
|
||||
long jsContextNativePointer,
|
||||
long eventHandlerPointer,
|
||||
long eventTargetPointer,
|
||||
String type,
|
||||
NativeMap payload
|
||||
);
|
||||
|
||||
long jsContextNativePointer,
|
||||
long eventHandlerPointer,
|
||||
long eventTargetPointer,
|
||||
String type,
|
||||
NativeMap payload);
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
package com.facebook.react.uimanager.events;
|
||||
|
||||
public interface BatchEventDispatchedListener {
|
||||
|
||||
/**
|
||||
* Called after a batch of low priority events has been dispatched.
|
||||
*/
|
||||
void onBatchEventDispatched();
|
||||
|
||||
}
|
@ -20,6 +20,7 @@ import com.facebook.systrace.Systrace;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.annotation.Nullable;
|
||||
@ -90,6 +91,7 @@ public class EventDispatcher implements LifecycleEventListener {
|
||||
private final DispatchEventsRunnable mDispatchEventsRunnable = new DispatchEventsRunnable();
|
||||
private final ArrayList<Event> mEventStaging = new ArrayList<>();
|
||||
private final ArrayList<EventDispatcherListener> mListeners = new ArrayList<>();
|
||||
private final List<BatchEventDispatchedListener> mPostEventDispatchListeners = new ArrayList<>();
|
||||
private final ScheduleDispatchFrameCallback mCurrentFrameCallback =
|
||||
new ScheduleDispatchFrameCallback();
|
||||
private final AtomicInteger mHasDispatchScheduledCount = new AtomicInteger();
|
||||
@ -149,6 +151,14 @@ public class EventDispatcher implements LifecycleEventListener {
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void addBatchEventDispatchedListener(BatchEventDispatchedListener listener) {
|
||||
mPostEventDispatchListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeBatchEventDispatchedListener(BatchEventDispatchedListener listener) {
|
||||
mPostEventDispatchListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostResume() {
|
||||
mCurrentFrameCallback.maybePostFromNonUI();
|
||||
@ -355,6 +365,9 @@ public class EventDispatcher implements LifecycleEventListener {
|
||||
event.dispatch(mReactEventEmitter);
|
||||
event.dispose();
|
||||
}
|
||||
for (BatchEventDispatchedListener listener : mPostEventDispatchListeners) {
|
||||
listener.onBatchEventDispatched();
|
||||
}
|
||||
clearEventsToDispatch();
|
||||
mEventCookieToLastEventIdx.clear();
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ package com.facebook.react.uimanager.events;
|
||||
|
||||
import static com.facebook.react.uimanager.events.TouchesHelper.TARGET_KEY;
|
||||
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
@ -17,8 +16,6 @@ import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.uimanager.common.UIManagerType;
|
||||
import com.facebook.react.uimanager.common.ViewUtil;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ReactEventEmitter implements RCTEventEmitter {
|
||||
|
Loading…
x
Reference in New Issue
Block a user