mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
aa5edca0e2
Summary: This diff migrates the usages Nullable and NonNull annotations to AndroidX instead of javax. The purpose of this change is to bring consistency in the annotations used by the core of RN Reviewed By: makovkastar Differential Revision: D16054504 fbshipit-source-id: 21d888854da088d2a14615a90d4dc058e5286b91
47 lines
1.6 KiB
Java
47 lines
1.6 KiB
Java
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* <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.animated;
|
|
|
|
import androidx.annotation.Nullable;
|
|
import com.facebook.react.bridge.ReadableMap;
|
|
import com.facebook.react.bridge.WritableArray;
|
|
import com.facebook.react.bridge.WritableMap;
|
|
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
import java.util.List;
|
|
|
|
/** Handles updating a {@link ValueAnimatedNode} when an event gets dispatched. */
|
|
/* package */ class EventAnimationDriver implements RCTEventEmitter {
|
|
private List<String> mEventPath;
|
|
/* package */ ValueAnimatedNode mValueNode;
|
|
|
|
public EventAnimationDriver(List<String> eventPath, ValueAnimatedNode valueNode) {
|
|
mEventPath = eventPath;
|
|
mValueNode = valueNode;
|
|
}
|
|
|
|
@Override
|
|
public void receiveEvent(int targetTag, String eventName, @Nullable WritableMap event) {
|
|
if (event == null) {
|
|
throw new IllegalArgumentException("Native animated events must have event data.");
|
|
}
|
|
|
|
// Get the new value for the node by looking into the event map using the provided event path.
|
|
ReadableMap curMap = event;
|
|
for (int i = 0; i < mEventPath.size() - 1; i++) {
|
|
curMap = curMap.getMap(mEventPath.get(i));
|
|
}
|
|
|
|
mValueNode.mValue = curMap.getDouble(mEventPath.get(mEventPath.size() - 1));
|
|
}
|
|
|
|
@Override
|
|
public void receiveTouches(
|
|
String eventName, WritableArray touches, WritableArray changedIndices) {
|
|
throw new RuntimeException("receiveTouches is not support by native animated events");
|
|
}
|
|
}
|