This file contains hidden or 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
| AppInitializer.getInstance(context).initializeComponent(MyInitializer::class.java) |
This file contains hidden or 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
| <manifest> | |
| <application> | |
| <provider | |
| android:name="androidx.startup.InitializationProvider" | |
| android:authorities="${applicationId}.androidx-startup" | |
| android:exported="false" | |
| tools:node="merge"> | |
| <!-- Manually/Lazily run MyInitializer --> | |
| <meta-data |
This file contains hidden or 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
| <manifest> | |
| <application> | |
| <provider | |
| android:name="androidx.startup.InitializationProvider" | |
| android:authorities="${applicationId}.androidx-startup" | |
| android:exported="false" | |
| tools:node="merge"> | |
| <!-- Automatically runs FaceDetectorInitializer and CameraInitializer at app startup --> | |
| <meta-data |
This file contains hidden or 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
| <manifest> | |
| <application> | |
| <provider | |
| android:name="androidx.startup.InitializationProvider" | |
| android:authorities="${applicationId}.androidx-startup" | |
| android:exported="false" | |
| tools:node="merge"> | |
| <!-- Automatically run MyInitializer at app startup --> | |
| <meta-data |
This file contains hidden or 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
| class FaceDetectorInitializer : Initializer<FaceDetector> { | |
| override fun create(context: Context): FaceDetector { | |
| val faceDetector = /* Set up and configure the face detector */ | |
| return faceDetector | |
| } | |
| override fun dependencies() = listOf(CameraInitializer::class.java) | |
| } |
This file contains hidden or 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
| class CameraInitializer : Initializer<Camera> { | |
| override fun create(context: Context): Camera { | |
| val camera = /* Set up, configure and/or initialize the camera */ | |
| return camera | |
| } | |
| override fun dependencies() = emptyList<>() | |
| } |
This file contains hidden or 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
| class MyInitializer: Initializer<MyDependency> { | |
| override fun create(context: Context): MyDependency { | |
| val myDependency: MyDependency = /* Run initialization/configuration logic */ | |
| return myDependency | |
| } | |
| override fun dependencies(): List<Class<out Initializer<*>>> { | |
| return listOf(AnotherDependencyInitializer::class.java, | |
| YetAnotherDependencyInitializer::class.java) |
This file contains hidden or 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
| implementation "androidx.startup:startup-runtime:1.0.0-alpha01" |
This file contains hidden or 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
| @Test | |
| fun shouldSendData() { | |
| val scenario = FragmentScenario.launchInContainer(FragmentB::class.java) | |
| // Register result listener | |
| var receivedData = "" | |
| scenario.onFragment { fragment -> | |
| fragment.parentFragmentManager.setFragmentResultListener( | |
| KEY, | |
| fragment, |
This file contains hidden or 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
| @Test | |
| fun shouldReceiveData() { | |
| val scenario = FragmentScenario.launchInContainer(FragmentA::class.java) | |
| // Pass data using the parent fragment manager | |
| scenario.onFragment { fragment -> | |
| val data = bundleOf(KEY_DATA to "value") | |
| fragment.parentFragmentManager.setFragmentResult("aKey", data) | |
| } |