/
RNSharedElementModule.java
49 lines (41 loc) · 1.82 KB
/
RNSharedElementModule.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
package versioned.host.exp.exponent.modules.api.components.sharedelement;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.uimanager.UIBlock;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.NativeViewHierarchyManager;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = RNSharedElementModule.MODULE_NAME)
public class RNSharedElementModule extends ReactContextBaseJavaModule {
public static final String MODULE_NAME = "RNSharedElementTransition";
static String LOG_TAG = "RNSharedElementModule";
private RNSharedElementNodeManager mNodeManager;
public RNSharedElementModule(ReactApplicationContext reactContext) {
super(reactContext);
mNodeManager = new RNSharedElementNodeManager(reactContext);
}
@Override
public String getName() {
return MODULE_NAME;
}
RNSharedElementNodeManager getNodeManager() {
return mNodeManager;
}
@ReactMethod
public void configure(final ReadableMap config, final Promise promise) {
// Store a reference to the native view manager in the node-manager.
// This is done so that we can efficiently resolve a view when the
// start- and end props are set on the Transition view.
final ReactApplicationContext context = getReactApplicationContext();
final UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
uiManager.prependUIBlock(new UIBlock() {
@Override
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
mNodeManager.setNativeViewHierarchyManager(nativeViewHierarchyManager);
}
});
}
}