Convert ReactApplication to kotlin (#37987)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37987

Convert ReactApplication to kotlin

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D46772472

fbshipit-source-id: 70c6b9fad3e4e365434b59f184753ca23cf5ed56
This commit is contained in:
David Vacca
2023-06-25 00:29:55 -07:00
committed by Facebook GitHub Bot
parent ca9d74a377
commit 68fe124fdc
4 changed files with 30 additions and 27 deletions
@@ -471,6 +471,11 @@ android {
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
// Using '-Xjvm-default=all' to support usage of @JvmDefault in kotlin files
freeCompilerArgs = ['-Xjvm-default=all']
}
defaultConfig {
minSdk = 21
targetSdk = 33
@@ -89,7 +89,7 @@ public class ReactActivityDelegate {
}
public ReactHostInterface getReactHost() {
return ((ReactApplication) getPlainActivity().getApplication()).getReactHostInterface();
return ((ReactApplication) getPlainActivity().getApplication()).reactHostInterface();
}
public ReactInstanceManager getReactInstanceManager() {
@@ -1,26 +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;
import androidx.annotation.Nullable;
import com.facebook.react.interfaces.ReactHostInterface;
/** Interface that represents an instance of a React Native application */
public interface ReactApplication {
/** Get the default {@link ReactNativeHost} for this app. */
ReactNativeHost getReactNativeHost();
/**
* Get the default {@link ReactHostInterface} for this app. This method will be used by the new
* architecture of react native
*/
default @Nullable ReactHostInterface getReactHostInterface() {
return null;
}
}
@@ -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
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.interfaces.ReactHostInterface
@OptIn(UnstableReactNativeAPI::class)
/** Interface that represents an instance of a React Native application */
interface ReactApplication {
/** Get the default [ReactNativeHost] for this app. */
fun getReactNativeHost(): ReactNativeHost
/**
* Get the default [ReactHostInterface] for this app. This method will be used by the new
* architecture of react native
*/
@JvmDefault fun reactHostInterface(): ReactHostInterface? = null
}