AbstractProgressFragment

abstract class AbstractProgressFragment : Fragment
kotlin.Any
   ↳ androidx.fragment.app.Fragment
   ↳ androidx.navigation.dynamicfeatures.fragment.ui.AbstractProgressFragment

The base class for Fragments that handle dynamic feature installation.

When extending from this class, you are responsible for forwarding installation state changes to your UI via the provided hooks in onCancelled, onFailed, onProgress.

The installation process itself is handled within the AbstractProgressFragment itself. Navigation to the target destination will occur once the installation is completed.

Summary

Public constructors

<init>(contentLayoutId: Int)

Public methods

open Unit
onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)

open Unit
onCreate(savedInstanceState: Bundle?)

open Unit

open Unit

Protected methods

Unit

Navigates to an installed dynamic feature module or kicks off installation.

abstract Unit

Called when the user decided to cancel installation.

abstract Unit
onFailed(errorCode: Int)

Called when the installation has failed due to non-user issues.

open Unit

Called when requested module has been successfully installed, just before the NavController navigates to the final destination.

abstract Unit
onProgress(status: Int, bytesDownloaded: Long, bytesTotal: Long)

Called when there was a progress update for an active module download.

Inherited functions

Inherited extension functions

From androidx.fragment.app
Lazy<VM>
Fragment.activityViewModels(noinline factoryProducer: () -> ViewModelProvider.Factory = null)

Returns a property delegate to access parent activity's ViewModel, if factoryProducer is specified then ViewModelProvider.Factory returned by it will be used to create ViewModel first time.

Unit

Clears the stored result for the given requestKey.

Unit

Clears the stored FragmentResultListener for the given requestKey.

Lazy<VM>
Fragment.createViewModelLazy(viewModelClass: KClass<VM>, storeProducer: () -> ViewModelStore, factoryProducer: () -> ViewModelProvider.Factory = null)

Helper method for creation of ViewModelLazy, that resolves null passed as factoryProducer to default factory.

Unit
Fragment.setFragmentResult(requestKey: String, result: Bundle)

Sets the given result for the requestKey.

Unit
Fragment.setFragmentResultListener(requestKey: String, crossinline listener: (resultKey: String, bundle: Bundle) -> Unit)

Sets the FragmentResultListener for a given requestKey.

Lazy<VM>
Fragment.viewModels(noinline ownerProducer: () -> ViewModelStoreOwner = { this }, noinline factoryProducer: () -> ViewModelProvider.Factory = null)

Returns a property delegate to access ViewModel by default scoped to this Fragment:

From androidx.navigation.fragment
NavController

Find a NavController given a Fragment

NavArgsLazy<Args>

Returns a Lazy delegate to access the Fragment's arguments as an Args instance.

From androidx.navigation
Lazy<VM>
Fragment.navGraphViewModels(@IdRes navGraphId: Int, noinline factoryProducer: () -> ViewModelProvider.Factory = null)

Returns a property delegate to access a ViewModel scoped to a navigation graph present on the {@link NavController} back stack:

From androidx.activity.result
ActivityResultLauncher<Unit>
ActivityResultCaller.registerForActivityResult(contract: ActivityResultContract<I, O>, input: I, registry: ActivityResultRegistry, callback: (O) -> Unit)

A version of ActivityResultCaller.registerForActivityResult that additionally takes an input right away, producing a launcher that doesn't take any additional input when called.

ActivityResultLauncher<Unit>
ActivityResultCaller.registerForActivityResult(contract: ActivityResultContract<I, O>, input: I, callback: (O) -> Unit)

A version of ActivityResultCaller.registerForActivityResult that additionally takes an input right away, producing a launcher that doesn't take any additional input when called.

From androidx.lifecycle
suspend T
LifecycleOwner.whenCreated(block: suspend CoroutineScope.() -> T)

Runs the given block when the LifecycleOwner's Lifecycle is at least in Lifecycle.State.CREATED state.

suspend T
LifecycleOwner.whenResumed(block: suspend CoroutineScope.() -> T)

Runs the given block when the LifecycleOwner's Lifecycle is at least in Lifecycle.State.RESUMED state.

suspend T
LifecycleOwner.whenStarted(block: suspend CoroutineScope.() -> T)

Runs the given block when the LifecycleOwner's Lifecycle is at least in Lifecycle.State.STARTED state.

Inherited extension properties

From androidx.lifecycle
LifecycleCoroutineScope

CoroutineScope tied to this LifecycleOwner's Lifecycle.

Public constructors

<init>

AbstractProgressFragment()

<init>

AbstractProgressFragment(contentLayoutId: Int)

Public methods

onActivityResult

open fun onActivityResult(
    requestCode: Int,
    resultCode: Int,
    data: Intent?
): Unit

onCreate

open fun onCreate(savedInstanceState: Bundle?): Unit

onResume

open fun onResume(): Unit

onSaveInstanceState

open fun onSaveInstanceState(outState: Bundle): Unit

Protected methods

protected fun navigate(): Unit

Navigates to an installed dynamic feature module or kicks off installation.

onCancelled

protected abstract fun onCancelled(): Unit

Called when the user decided to cancel installation.

onFailed

protected abstract fun onFailed(errorCode: Int): Unit

Called when the installation has failed due to non-user issues.

Please check SplitInstallErrorCode for error code constants.

Parameters
errorCode: Int contains the error code of the installation failure.

onInstalled

protected open fun onInstalled(): Unit

Called when requested module has been successfully installed, just before the NavController navigates to the final destination.

onProgress

protected abstract fun onProgress(
    status: Int,
    bytesDownloaded: Long,
    bytesTotal: Long
): Unit

Called when there was a progress update for an active module download.

Parameters
status: Int the current installation status from SplitInstallSessionStatus
bytesDownloaded: Long The bytes downloaded so far.
bytesTotal: Long The total bytes to be downloaded (can be 0 for some status updates)