android-components / mozilla.components.feature.downloads / DownloadDialogFragment

DownloadDialogFragment

abstract class DownloadDialogFragment : AppCompatDialogFragment (source)

This is a general representation of a dialog meant to be used in collaboration with DownloadsFeature to show a dialog before a download is triggered. If SimpleDownloadDialogFragment is not flexible enough for your use case you should inherit for this class. Be mindful to call onStartDownload when you want to start the download.

Constructors

Name Summary
<init> DownloadDialogFragment()
This is a general representation of a dialog meant to be used in collaboration with DownloadsFeature to show a dialog before a download is triggered. If SimpleDownloadDialogFragment is not flexible enough for your use case you should inherit for this class. Be mindful to call onStartDownload when you want to start the download.

Properties

Name Summary
onCancelDownload var onCancelDownload: () -> Unit
onStartDownload var onStartDownload: () -> Unit
A callback to trigger a download, call it when you are ready to start a download. For instance, a valid use case can be in confirmation dialog, after the positive button is clicked, this callback must be called.

Functions

Name Summary
setDownload fun setDownload(download: DownloadState): Unit
Add the metadata of this download object to the arguments of this fragment.

Companion Object Properties

Name Summary
FRAGMENT_TAG const val FRAGMENT_TAG: String
KEY_CONTENT_LENGTH const val KEY_CONTENT_LENGTH: String
Key for finding the content length in the arguments.
KEY_FILE_NAME const val KEY_FILE_NAME: String
Key for finding the file name in the arguments.
KEY_URL const val KEY_URL: String
Key for finding the url in the arguments.
MEGABYTE const val MEGABYTE: Double

Extension Functions

Name Summary
consumeFrom fun <S : State, A : Action> Fragment.consumeFrom(store: Store<S, A>, block: (S) -> Unit): Unit
Helper extension method for consuming State from a Store sequentially in order inside a Fragment. The block function will get invoked for every State update.
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.

Inheritors

Name Summary
SimpleDownloadDialogFragment class SimpleDownloadDialogFragment : DownloadDialogFragment
A confirmation dialog to be called before a download is triggered. Meant to be used in collaboration with DownloadsFeature