-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(android): handle
ReactApplication
changes to getters (#1483)
Signature changes were introduced in facebook/react-native@c3f672c.
- Loading branch information
Showing
7 changed files
with
98 additions
and
25 deletions.
There are no files selected for viewing
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
5 changes: 2 additions & 3 deletions
5
android/app/src/main/java/com/microsoft/reacttestapp/manifest/Manifest.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
64 changes: 64 additions & 0 deletions
64
android/app/src/reactapplication-0.73/java/com/microsoft/reacttestapp/TestApp.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,64 @@ | ||
package com.microsoft.reacttestapp | ||
|
||
import android.app.Activity | ||
import android.app.Application | ||
import android.content.Context | ||
import com.facebook.react.PackageList | ||
import com.facebook.react.ReactApplication | ||
import com.facebook.soloader.SoLoader | ||
import com.microsoft.reacttestapp.manifest.ManifestProvider | ||
import com.microsoft.reacttestapp.react.ReactBundleNameProvider | ||
import com.microsoft.reacttestapp.react.TestAppReactNativeHost | ||
import com.microsoft.reacttestapp.support.ReactTestAppLifecycleEvents | ||
|
||
class TestApp : Application(), ReactApplication { | ||
val bundleNameProvider: ReactBundleNameProvider | ||
get() = reactNativeBundleNameProvider | ||
|
||
val manifestProvider: ManifestProvider | ||
get() = manifestProviderInternal | ||
|
||
override val reactNativeHost: TestAppReactNativeHost | ||
get() = reactNativeHostInternal | ||
|
||
private lateinit var manifestProviderInternal: ManifestProvider | ||
private lateinit var reactNativeBundleNameProvider: ReactBundleNameProvider | ||
private lateinit var reactNativeHostInternal: TestAppReactNativeHost | ||
|
||
fun reloadJSFromServer(activity: Activity?, bundleURL: String) { | ||
reactNativeHostInternal.reloadJSFromServer(activity, bundleURL) | ||
} | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
// We need to initialize SoLoader early because ManifestProvider may | ||
// need to use WritableNativeMap when parsing initial properties. | ||
SoLoader.init(this, false) | ||
|
||
manifestProviderInternal = ManifestProvider.create(this) | ||
val (manifest, _) = manifestProvider.fromResources() | ||
|
||
reactNativeBundleNameProvider = ReactBundleNameProvider(this, manifest.bundleRoot) | ||
reactNativeHostInternal = | ||
TestAppReactNativeHost(this, reactNativeBundleNameProvider) | ||
|
||
val eventConsumers = PackageList(this).packages | ||
.filter { it is ReactTestAppLifecycleEvents } | ||
.map { it as ReactTestAppLifecycleEvents } | ||
|
||
eventConsumers.forEach { it.onTestAppInitialized() } | ||
|
||
reactNativeHostInternal.init( | ||
beforeReactNativeInit = { | ||
eventConsumers.forEach { it.onTestAppWillInitializeReactNative() } | ||
}, | ||
afterReactNativeInit = { | ||
eventConsumers.forEach { it.onTestAppDidInitializeReactNative() } | ||
} | ||
) | ||
} | ||
} | ||
|
||
val Context.testApp: TestApp | ||
get() = applicationContext as TestApp |
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
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
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
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