forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate RNTesterActivity to Kotlin (facebook#39584)
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
1 parent
2fb4547
commit 0f2ecd3
Showing
2 changed files
with
40 additions
and
59 deletions.
There are no files selected for viewing
59 changes: 0 additions & 59 deletions
59
packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.java
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |