66import com .facebook .react .bridge .WritableMap ;
77import com .facebook .react .uimanager .PixelUtil ;
88import com .facebook .react .uimanager .events .Event ;
9+ import com .facebook .react .uimanager .events .RCTEventEmitter ;
910
1011public class SvgOnLayoutEvent extends Event <SvgOnLayoutEvent > {
1112
13+ public static final String EVENT_NAME = "topLayout" ;
1214 public int x = 0 ;
1315 public int y = 0 ;
1416 public int width = 0 ;
1517 public int height = 0 ;
1618
17- private SvgOnLayoutEvent () {}
18-
19- @ Override
20- public void onDispose () {
21- EVENTS_POOL .release (this );
22- }
23-
24- protected void init (int surfaceId , int viewTag , int x , int y , int width , int height ) {
25- super .init (surfaceId , viewTag );
19+ public SvgOnLayoutEvent (int surfaceId , int viewId , int x , int y , int width , int height ) {
20+ super (surfaceId , viewId );
2621 this .x = x ;
2722 this .y = y ;
2823 this .width = width ;
@@ -31,11 +26,21 @@ protected void init(int surfaceId, int viewTag, int x, int y, int width, int hei
3126
3227 @ Override
3328 public String getEventName () {
34- return "topLayout" ;
29+ return EVENT_NAME ;
30+ }
31+
32+ @ Override
33+ public short getCoalescingKey () {
34+ return 0 ;
35+ }
36+
37+ @ Override
38+ public void dispatch (RCTEventEmitter rctEventEmitter ) {
39+ rctEventEmitter .receiveEvent (getViewTag (), getEventName (), getEventData ());
3540 }
3641
3742 @ Override
38- public WritableMap getEventData () {
43+ protected WritableMap getEventData () {
3944 WritableMap layout = Arguments .createMap ();
4045 layout .putDouble ("x" , (double ) PixelUtil .toDIPFromPixel ((float ) x ));
4146 layout .putDouble ("y" , (double ) PixelUtil .toDIPFromPixel ((float ) y ));
@@ -48,20 +53,4 @@ public WritableMap getEventData() {
4853
4954 return event ;
5055 }
51-
52- private static final SynchronizedPool <SvgOnLayoutEvent > EVENTS_POOL =
53- new SynchronizedPool <SvgOnLayoutEvent >(20 );
54-
55- public static SvgOnLayoutEvent obtain (int viewTag , int x , int y , int width , int height ) {
56- return obtain (-1 , viewTag , x , y , width , height );
57- }
58-
59- public static SvgOnLayoutEvent obtain (int surfaceId , int viewTag , int x , int y , int width , int height ) {
60- SvgOnLayoutEvent event = EVENTS_POOL .acquire ();
61- if (event == null ) {
62- event = new SvgOnLayoutEvent ();
63- }
64- event .init (surfaceId , viewTag , x , y , width , height );
65- return event ;
66- }
6756}
0 commit comments