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
<dist:module | |
dist:instant="false" | |
dist:title="@string/title_ondemand"> | |
<dist:delivery> | |
<dist:on-demand /> | |
</dist:delivery> | |
<dist:fusing dist:include="true" /> | |
</dist:module> |
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
android { | |
... | |
dynamicFeatures = [":ondemand"] | |
} |
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 DynamicApp : Application() { | |
override fun attachBaseContext(base: Context?) { | |
super.attachBaseContext(base) | |
SplitCompat.install(this) | |
} | |
} |
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 OnDemandActivity : AppCompatActivity() { | |
// other lifecycle functions | |
override fun attachBaseContext(base: Context?) { | |
super.attachBaseContext(base) | |
SplitCompat.install(this) | |
} | |
} |
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
val request = SplitInstallRequest.newBuilder() | |
.addModule("ondemand") | |
.build() | |
manager.startInstall(request) |
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
manager.registerListener { | |
when (it.status()) { | |
SplitInstallSessionStatus.DOWNLOADING -> showToast("Downloading feature") | |
SplitInstallSessionStatus.INSTALLED -> { | |
showToast("Feature ready to be used") | |
updateDynamicFeatureButtonState() | |
} | |
else -> { /* Do nothing in this example */ } | |
} | |
} |
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
val intent = Intent() | |
intent.setClassName(BuildConfig.APPLICATION_ID, "com.escodro.ondemand.OnDemandActivity") | |
startActivity(intent) |
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
private val manager: SplitInstallManager by lazy { | |
SplitInstallManagerFactory.create(this) | |
} |
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
val isEnabled = manager.installedModules.contains("ondemand") | |
button_app_open.isEnabled = isEnabled |
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
/** | |
* Public Composable to do not expose internal ViewModel to other modules. | |
*/ | |
@Composable | |
fun TaskListSection(modifier: Modifier = Modifier) { | |
TaskListLoader(modifier = modifier) | |
} | |
/** | |
* Private Composable to connect the ViewModel and View. |
OlderNewer