This library helps to show a Dialog
and takes care of sending events to the parent Activity
/Fragment
without leaking it even if the dialogs are shown as DialogFragments
. It's made for the Theme.Material3
theme and tries to follow styling that's described here:
It supports following styling "types" and changing between styles is as simple as calling a different show function:
- AlertDialog
- DialogFragment
- BottomSheetDialogFragment
- FullscreenDialog
All the Fragment
modes support restoring intermdediate view states and automatic restoration of the event emission logic to the correct parent without leaking it.
Additionally, the dialogs support View
based animations as well like e.g. CircularReveal
.
Gradle (via JitPack.io)
- add jitpack to your project's
build.gradle
:
repositories {
maven { url "https://jitpack.io" }
}
- add the compile statement to your module's
build.gradle
:
dependencies {
// core module - contains the common logic and allows to display a dialog as "AlertDialog"
implementation "com.github.MFlisar.MaterialDialogs:core:<LATEST-VERSION>"
// dialog modules
implementation "com.github.MFlisar.MaterialDialogs:dialogs-info:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:dialogs-input:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:dialogs-list:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:dialogs-number:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:dialogs-datetime:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:dialogs-color:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:dialogs-ads:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:dialogs-gdpr:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:dialogs-billing:<LATEST-VERSION>"
// extensions for additional "display modes" and for custom animations
implementation "com.github.MFlisar.MaterialDialogs:extensions-animations:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:extensions-fragment-dialog:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:extensions-fragment-bottomsheet:<LATEST-VERSION>"
implementation "com.github.MFlisar.MaterialDialogs:extensions-fragment-fullscreen:<LATEST-VERSION>"
}
It works as simple as following: From within an Activity
/Fragment
create a dialog like following:
DialogInfo(
id = 1,
title = "Info Title".asText(), // Int, String and any CharSequence are supported (e.g. SpannableString)
text = "Some info text...".asText(),
extra = <SOME OPTIONAL DATA> // attach any additional data (it must be parcelable) you may want to use when handling the result
)
.showAlertDialog(context) // simple context is enough for the AlertDialog mode
// OR following ( parent is a fragment or an activity)
.showDialogFragment(parent)
.showBottomSheetDialogFragment(parent)
.showFullscreenFragment(parent)
From any lifecycle aware component (like e.g. an Activity
/Fragment
) you can do then following:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// - ID is optional, you can also listen to all events of a special type if desired
// - onMaterialDialogEvent is an extension function on LifecycleOwner
onMaterialDialogEvent<DialogInfo.Event>(id = 1) { event ->
// dialog event received -> process it...
}
}
Additionally, the AlertDialog
mode does support providing a direct callback, simply like following:
DialogInfo(...)
.showAlertDialog(parent) { event ->
// event of Type "DialogInfo.Event" will be directly emitted here...
}
That's it, the library will take care to unregister the listener if the Activity
/Fragment
is destroyed and will avoid leaks like this. Even though the DialogFragments
are recreated automatically after restoration and screen rotation the parent will be able to receive all events without any further code requirements by the developer.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Readmes are split up for each module and can be found inside the doc
folder, here are the links:
Check the demo app for more informations.
- ButtonsView: support stacking
- Swipe Dismiss Feature
- Features
- BottomSheet - flag to support "expand to fullscreen style" (pos button in toolbar is enabled, pos button in footer is removed, toolbar replaces the title)
- Dialogss
- Info
- Input
- List
- NumberPicker
- DateTime (=> Custom Impl with material design?)
- Color
- Ads
- GDPR
- Billing
- Frequency