Skip to content

Commit

Permalink
add kotlin injections - androidtv
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaDiachenko committed Feb 5, 2024
1 parent 6a43872 commit 428ce09
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package {{APPLICATION_ID}}

import android.os.Bundle
import android.content.Intent
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate

{{PLUGIN_ACTIVITY_IMPORTS}}

class MainActivity : ReactActivity() {

/**
Expand All @@ -13,6 +17,23 @@ class MainActivity : ReactActivity() {
*/
override fun getMainComponentName(): String = "RNVApp"

override fun onCreate(savedInstanceState: Bundle?) {
{{INJECT_ON_CREATE}}
{{PLUGIN_ON_CREATE}}
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
{{PLUGIN_ON_ACTIVITY_RESULT}}
}

override fun onNewIntent(intent:Intent) {
setIntent(intent)
super.onNewIntent(intent)
}

{{PLUGIN_ACTIVITY_METHODS}}

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,27 @@ import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.soloader.SoLoader

{{PLUGIN_IMPORTS}}

class MainApplication : Application(), ReactApplication {

override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
{{PLUGIN_PACKAGES}}
}

override fun getJSMainModuleName(): String = "index"
override fun getJSMainModuleName(): String = "{{ENTRY_FILE}}"

override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG

override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}

{{PLUGIN_METHODS}}

override val reactHost: ReactHost
get() = getDefaultReactHost(this.applicationContext, reactNativeHost)

Expand All @@ -39,5 +42,6 @@ class MainApplication : Application(), ReactApplication {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
{{PLUGIN_ON_CREATE}}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package {{APPLICATION_ID}}

import android.os.Bundle
import android.content.Intent
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate

{{PLUGIN_ACTIVITY_IMPORTS}}

class MainActivity : ReactActivity() {

/**
Expand All @@ -13,6 +17,23 @@ class MainActivity : ReactActivity() {
*/
override fun getMainComponentName(): String = "RNVApp"

override fun onCreate(savedInstanceState: Bundle?) {
{{INJECT_ON_CREATE}}
{{PLUGIN_ON_CREATE}}
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
{{PLUGIN_ON_ACTIVITY_RESULT}}
}

override fun onNewIntent(intent:Intent) {
setIntent(intent)
super.onNewIntent(intent)
}

{{PLUGIN_ACTIVITY_METHODS}}

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,27 @@ import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.soloader.SoLoader

{{PLUGIN_IMPORTS}}

class MainApplication : Application(), ReactApplication {

override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
{{PLUGIN_PACKAGES}}
}

override fun getJSMainModuleName(): String = "index"
override fun getJSMainModuleName(): String = "{{ENTRY_FILE}}"

override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG

override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}

{{PLUGIN_METHODS}}

override val reactHost: ReactHost
get() = getDefaultReactHost(this.applicationContext, reactNativeHost)

Expand All @@ -39,5 +42,6 @@ class MainApplication : Application(), ReactApplication {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
{{PLUGIN_ON_CREATE}}
}
}

0 comments on commit 428ce09

Please sign in to comment.