-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
ReactSlidingCompleteEvent.java
60 lines (47 loc) · 1.48 KB
/
ReactSlidingCompleteEvent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* 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.
*/
package com.reactnativecommunity.slider;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.RCTEventEmitter;
/**
* Event emitted when the user finishes dragging the slider.
*/
public class ReactSlidingCompleteEvent extends Event<ReactSlidingCompleteEvent> {
public static final String EVENT_NAME = "topSlidingComplete";
private final double mValue;
public ReactSlidingCompleteEvent(int viewId, double value) {
super(viewId);
mValue = value;
}
public double getValue() {
return mValue;
}
@Override
public String getEventName() {
return EVENT_NAME;
}
@Override
public short getCoalescingKey() {
return 0;
}
@Override
public boolean canCoalesce() {
return false;
}
@Override
public void dispatch(RCTEventEmitter rctEventEmitter) {
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData());
}
private WritableMap serializeEventData() {
WritableMap eventData = Arguments.createMap();
eventData.putInt("target", getViewTag());
eventData.putDouble("value", getValue());
return eventData;
}
}