Skip to content

Commit

Permalink
migrate RNTesterActivity to Kotlin (facebook#39584)
Browse files Browse the repository at this point in the history
Summary:
PR converts RNTesterActivity to Kotlin as requested in facebook#38825 .

## Changelog:

[INTERNAL] [CHANGED] - Migrate RNTesterActivity to Kotlin

Pull Request resolved: facebook#39584

Test Plan:
1. run `yarn android`
2. Check whether RN Tester runs as expected

Reviewed By: cortinico

Differential Revision: D49506304

Pulled By: ryancat

fbshipit-source-id: 7675b43e6ef1d09f9a6e09e5a70526fc59f07bbf
  • Loading branch information
BogiKay authored and facebook-github-bot committed Sep 22, 2023
1 parent 2fb4547 commit 0f2ecd3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 59 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.uiapp

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

class RNTesterActivity : ReactActivity() {
class RNTesterActivityDelegate(val activity: ReactActivity, mainComponentName: String) :
DefaultReactActivityDelegate(activity, mainComponentName, fabricEnabled) {
private val PARAM_ROUTE = "route"
private lateinit var initialProps: Bundle

override fun onCreate(savedInstanceState: Bundle?) {
// Get remote param before calling super which uses it
val bundle = activity.getIntent()?.getExtras()

if (bundle != null && bundle.containsKey(PARAM_ROUTE)) {
val routeUri = "rntester://example/${bundle.getString(PARAM_ROUTE)}Example"
initialProps = Bundle()
initialProps?.putString("exampleFromAppetizeParams", routeUri)
}

super.onCreate(savedInstanceState)
}

override fun getLaunchOptions() = initialProps
}

override fun createReactActivityDelegate() = RNTesterActivityDelegate(this, mainComponentName)

override fun getMainComponentName() = "RNTesterApp"
}

0 comments on commit 0f2ecd3

Please sign in to comment.