正在查看: CityMall v1.42.1 应用的 NativeProxyCommon.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: CityMall v1.42.1 应用的 NativeProxyCommon.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.swmansion.reanimated.nativeProxy;
import android.os.SystemClock;
import android.provider.Settings;
import android.util.Log;
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableNativeArray;
import com.facebook.react.devsupport.interfaces.DevOptionHandler;
import com.facebook.soloader.SoLoader;
import com.swmansion.common.GestureHandlerStateManager;
import com.swmansion.gesturehandler.react.RNGestureHandlerModule;
import com.swmansion.reanimated.BuildConfig;
import com.swmansion.reanimated.DevMenuUtils;
import com.swmansion.reanimated.NativeProxy;
import com.swmansion.reanimated.NodesManager;
import com.swmansion.reanimated.ReanimatedModule;
import com.swmansion.reanimated.Utils;
import com.swmansion.reanimated.keyboard.KeyboardAnimationManager;
import com.swmansion.reanimated.keyboard.KeyboardWorkletWrapper;
import com.swmansion.reanimated.layoutReanimation.LayoutAnimations;
import com.swmansion.reanimated.sensor.ReanimatedSensorContainer;
import com.swmansion.reanimated.sensor.ReanimatedSensorType;
import com.swmansion.worklets.WorkletsModule;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
public abstract class NativeProxyCommon {
private final GestureHandlerStateManager gestureHandlerStateManager;
private final KeyboardAnimationManager keyboardAnimationManager;
protected final WeakReference<ReactApplicationContext> mContext;
protected NodesManager mNodesManager;
protected final WorkletsModule mWorkletsModule;
private final ReanimatedSensorContainer reanimatedSensorContainer;
private Long firstUptime = Long.valueOf(SystemClock.uptimeMillis());
private boolean slowAnimationsEnabled = false;
private final int ANIMATIONS_DRAG_FACTOR = 10;
protected String cppVersion = null;
static {
SoLoader.t("reanimated");
}
protected NativeProxyCommon(ReactApplicationContext reactApplicationContext) {
GestureHandlerStateManager gestureHandlerStateManager = null;
ReanimatedModule nativeModule = reactApplicationContext.getNativeModule(ReanimatedModule.class);
Objects.requireNonNull(nativeModule);
this.mWorkletsModule = nativeModule.getWorkletsModule();
WeakReference<ReactApplicationContext> weakReference = new WeakReference<>(reactApplicationContext);
this.mContext = weakReference;
this.reanimatedSensorContainer = new ReanimatedSensorContainer(weakReference);
this.keyboardAnimationManager = new KeyboardAnimationManager(weakReference);
addDevMenuOption();
try {
RNGestureHandlerModule.a aVar = RNGestureHandlerModule.Companion;
gestureHandlerStateManager = (GestureHandlerStateManager) reactApplicationContext.getNativeModule(RNGestureHandlerModule.class);
} catch (ClassCastException | ClassNotFoundException unused) {
}
this.gestureHandlerStateManager = gestureHandlerStateManager;
}
private void addDevMenuOption() {
DevMenuUtils.addDevMenuOption(this.mContext.get(), new DevOptionHandler() {
public final void a() {
NativeProxyCommon.this.toggleSlowAnimations();
}
});
}
private Set<String> convertProps(ReadableNativeArray readableNativeArray) {
HashSet hashSet = new HashSet();
ArrayList arrayList = readableNativeArray.toArrayList();
for (int i = 0; i < arrayList.size(); i++) {
hashSet.add((String) arrayList.get(i));
}
return hashSet;
}
public void toggleSlowAnimations() {
boolean z = this.slowAnimationsEnabled;
this.slowAnimationsEnabled = !z;
if (!z) {
this.firstUptime = Long.valueOf(SystemClock.uptimeMillis());
}
this.mNodesManager.enableSlowAnimations(this.slowAnimationsEnabled, 10);
}
protected void checkCppVersion() {
if (this.cppVersion == null) {
throw new RuntimeException("[Reanimated] Java side failed to resolve C++ code version. See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#java-side-failed-to-resolve-c-code-version for more information.");
}
String reanimatedJavaVersion = getReanimatedJavaVersion();
if (this.cppVersion.equals(reanimatedJavaVersion)) {
return;
}
throw new RuntimeException("[Reanimated] Mismatch between Java code version and C++ code version (" + reanimatedJavaVersion + " vs. " + this.cppVersion + " respectively). See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#mismatch-between-java-code-version-and-c-code-version for more information.");
}
@DoNotStrip
public void configureProps(ReadableNativeArray readableNativeArray, ReadableNativeArray readableNativeArray2) {
this.mNodesManager.configureProps(convertProps(readableNativeArray), convertProps(readableNativeArray2));
}
@DoNotStrip
public void dispatchCommand(int i, String str, ReadableArray readableArray) {
this.mNodesManager.dispatchCommand(i, str, readableArray);
}
@DoNotStrip
public long getAnimationTimestamp() {
return this.slowAnimationsEnabled ? this.firstUptime.longValue() + ((SystemClock.uptimeMillis() - this.firstUptime.longValue()) / 10) : SystemClock.uptimeMillis();
}
protected abstract HybridData getHybridData();
@DoNotStrip
public boolean getIsReducedMotion() {
String string = Settings.Global.getString(this.mContext.get().getContentResolver(), "transition_animation_scale");
return (string != null ? Float.parseFloat(string) : 1.0f) == 0.0f;
}
@DoNotStrip
public String getReanimatedJavaVersion() {
return BuildConfig.REANIMATED_VERSION_JAVA;
}
protected native void installJSIBindings();
@DoNotStrip
void maybeFlushUIUpdatesQueue() {
if (this.mNodesManager.isAnimationRunning()) {
return;
}
this.mNodesManager.performOperations();
}
@DoNotStrip
public float[] measure(int i) {
return this.mNodesManager.measure(i);
}
@DoNotStrip
public String obtainProp(int i, String str) {
return this.mNodesManager.obtainProp(i, str);
}
public void prepareLayoutAnimations(LayoutAnimations layoutAnimations) {
if (Utils.isChromeDebugger) {
Log.w("[REANIMATED]", "You can not use LayoutAnimation with enabled Chrome Debugger");
return;
}
ReanimatedModule nativeModule = this.mContext.get().getNativeModule(ReanimatedModule.class);
Objects.requireNonNull(nativeModule);
this.mNodesManager = nativeModule.getNodesManager();
ReanimatedModule nativeModule2 = this.mContext.get().getNativeModule(ReanimatedModule.class);
Objects.requireNonNull(nativeModule2);
nativeModule2.getNodesManager().getAnimationsManager().setNativeMethods(NativeProxy.createNativeMethodsHolder(layoutAnimations));
}
@DoNotStrip
public void registerEventHandler(EventHandler eventHandler) {
eventHandler.mCustomEventNamesResolver = this.mNodesManager.getEventNameResolver();
this.mNodesManager.registerEventHandler(eventHandler);
}
@DoNotStrip
public int registerSensor(int i, int i2, SensorSetter sensorSetter) {
return this.reanimatedSensorContainer.registerSensor(ReanimatedSensorType.getInstanceById(i), i2, sensorSetter);
}
@DoNotStrip
public void requestRender(AnimationFrameCallback animationFrameCallback) {
this.mNodesManager.postOnAnimation(animationFrameCallback);
}
@DoNotStrip
public void scrollTo(int i, double d, double d2, boolean z) {
this.mNodesManager.scrollTo(i, d, d2, z);
}
@DoNotStrip
protected void setCppVersion(String str) {
this.cppVersion = str;
}
@DoNotStrip
public void setGestureState(int i, int i2) {
GestureHandlerStateManager gestureHandlerStateManager = this.gestureHandlerStateManager;
if (gestureHandlerStateManager != null) {
gestureHandlerStateManager.setGestureHandlerState(i, i2);
}
}
@DoNotStrip
public int subscribeForKeyboardEvents(KeyboardWorkletWrapper keyboardWorkletWrapper, boolean z, boolean z2) {
return this.keyboardAnimationManager.subscribeForKeyboardUpdates(keyboardWorkletWrapper, z, z2);
}
@DoNotStrip
public void unregisterSensor(int i) {
this.reanimatedSensorContainer.unregisterSensor(i);
}
@DoNotStrip
public void unsubscribeFromKeyboardEvents(int i) {
this.keyboardAnimationManager.unsubscribeFromKeyboardUpdates(i);
}
@DoNotStrip
public void updateProps(int i, Map<String, Object> map) {
this.mNodesManager.updateProps(i, map);
}
}