diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index cc97c622074f..55fcf4c72273 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1936,8 +1936,9 @@ public final class com/facebook/react/common/mapbuffer/WritableMapBuffer : com/f public final fun put (IZ)Lcom/facebook/react/common/mapbuffer/WritableMapBuffer; } -public class com/facebook/react/common/network/OkHttpCallUtil { - public static fun cancelTag (Lokhttp3/OkHttpClient;Ljava/lang/Object;)V +public final class com/facebook/react/common/network/OkHttpCallUtil { + public static final field INSTANCE Lcom/facebook/react/common/network/OkHttpCallUtil; + public static final fun cancelTag (Lokhttp3/OkHttpClient;Ljava/lang/Object;)V } public class com/facebook/react/config/ReactFeatureFlags { @@ -5867,9 +5868,9 @@ public class com/facebook/react/views/common/ContextUtils { public static fun findContextOfType (Landroid/content/Context;Ljava/lang/Class;)Ljava/lang/Object; } -public class com/facebook/react/views/common/ViewUtils { - public fun ()V - public static fun getTestId (Landroid/view/View;)Ljava/lang/String; +public final class com/facebook/react/views/common/ViewUtils { + public static final field INSTANCE Lcom/facebook/react/views/common/ViewUtils; + public static final fun getTestId (Landroid/view/View;)Ljava/lang/String; } public class com/facebook/react/views/debuggingoverlay/DebuggingOverlay : android/view/View { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.java deleted file mode 100644 index a71f7113dc0e..000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and 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.facebook.react.common.network; - -import com.facebook.infer.annotation.Nullsafe; -import okhttp3.Call; -import okhttp3.OkHttpClient; - -/** - * Helper class that provides the necessary methods for canceling queued and running OkHttp calls - */ -@Nullsafe(Nullsafe.Mode.LOCAL) -public class OkHttpCallUtil { - - private OkHttpCallUtil() {} - - public static void cancelTag(OkHttpClient client, Object tag) { - for (Call call : client.dispatcher().queuedCalls()) { - if (tag.equals(call.request().tag())) { - call.cancel(); - return; - } - } - for (Call call : client.dispatcher().runningCalls()) { - if (tag.equals(call.request().tag())) { - call.cancel(); - return; - } - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.kt new file mode 100644 index 000000000000..0bd4a0f11238 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/network/OkHttpCallUtil.kt @@ -0,0 +1,32 @@ +/* + * Copyright (c) Meta Platforms, Inc. and 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.facebook.react.common.network + +import okhttp3.OkHttpClient + +/** + * Helper class that provides the necessary methods for canceling queued and running OkHttp calls + */ +public object OkHttpCallUtil { + + @JvmStatic + public fun cancelTag(client: OkHttpClient, tag: Any) { + for (call in client.dispatcher().queuedCalls()) { + if (tag == call.request().tag()) { + call.cancel() + return + } + } + for (call in client.dispatcher().runningCalls()) { + if (tag == call.request().tag()) { + call.cancel() + return + } + } + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/SimpleViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/SimpleViewManager.kt similarity index 54% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/SimpleViewManager.java rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/SimpleViewManager.kt index 18be68007916..009e1658bed5 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/SimpleViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/SimpleViewManager.kt @@ -5,10 +5,9 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.uimanager; +package com.facebook.react.uimanager -import android.view.View; -import com.facebook.infer.annotation.Nullsafe; +import android.view.View /** * Common base class for most of the {@link ViewManager}s. It provides support for most common @@ -18,20 +17,15 @@ * * @param the view handled by this manager */ -@Nullsafe(Nullsafe.Mode.LOCAL) -public abstract class SimpleViewManager - extends BaseViewManager { +public abstract class SimpleViewManager : BaseViewManager() { - @Override - public LayoutShadowNode createShadowNodeInstance() { - return new LayoutShadowNode(); + override public fun createShadowNodeInstance(): LayoutShadowNode { + return LayoutShadowNode() } - @Override - public Class getShadowNodeClass() { - return LayoutShadowNode.class; + override public fun getShadowNodeClass(): Class { + return LayoutShadowNode::class.java } - @Override - public void updateExtraData(T root, Object extraData) {} + override public fun updateExtraData(root: T, extraData: Any?): Unit = Unit } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/common/ViewUtils.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/common/ViewUtils.java deleted file mode 100644 index 9a9d219ddf43..000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/common/ViewUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and 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.facebook.react.views.common; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.react.R; - -/** Class containing static methods involving manipulations of Views */ -@Nullsafe(Nullsafe.Mode.LOCAL) -public class ViewUtils { - - /** - * Returns value of testId for the given view, if present - * - * @param view View to get the testId value for - * @return the value of testId if defined for the view, otherwise null - */ - public static @Nullable String getTestId(@Nullable View view) { - if (view == null) { - return null; - } - Object tag = view.getTag(R.id.react_test_id); - if (tag instanceof String) { - return (String) tag; - } else { - return null; - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/common/ViewUtils.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/common/ViewUtils.kt new file mode 100644 index 000000000000..ccbe5b0306a4 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/common/ViewUtils.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) Meta Platforms, Inc. and 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.facebook.react.views.common + +import android.view.View +import com.facebook.react.R + +/** Class containing static methods involving manipulations of Views */ +public object ViewUtils { + + /** + * Returns value of testId for the given view, if present + * + * @param view View to get the testId value for + * @return the value of testId if defined for the view, otherwise null + */ + @JvmStatic + public fun getTestId(view: View?): String? = view?.getTag(R.id.react_test_id) as? String +}