The Android arsenal – dialogues


Common dialogue fragments based on https://github.com/afollestad/material-dialogs

characteristics

  • handles saving / restoring fragments for you automatically
  • Contains a mechanism for handling dialog events (even after the screen has been restored) within activities and / or fragments
  • Contains some special dialogs (extracted in separate modules), e.g. B. a user-defined color dialog, text and number dialogs, multiple text and number dialogs, a quick adapter recycler view dialog, an advertising dialog – possibly even more
  • also supports displaying dialogs as dialog or bottom sheet
  • Easily expandable – create your own dialogues, just take a look at the expansion modules

Screenshots

Gradle (via JitPack.io)

  1. Add jitpack to your project build.gradle::
repositories { maven { url "https://jitpack.io" }
}
  1. Add the implementation instructions to the modules build.gradle::
dependencies { // -------- // core - DialogInfo, DialogList, DialogProgress // -------- implementation "com.github.MFlisar.MaterialDialogFragments:dialogs:<LATEST-VERSION>" // -------- // optional // -------- // input - DialogInput, DialogNumber, DialogNumberPicker implementation "com.github.MFlisar.MaterialDialogFragments:dialogs-input:<LATEST-VERSION>" // specials  implementation "com.github.MFlisar.MaterialDialogFragments:dialogs-datetime:<LATEST-VERSION>" implementation "com.github.MFlisar.MaterialDialogFragments:dialogs-fastadapter:<LATEST-VERSION>" implementation "com.github.MFlisar.MaterialDialogFragments:dialogs-color:<LATEST-VERSION>" implementation "com.github.MFlisar.MaterialDialogFragments:dialogs-frequency:<LATEST-VERSION>" implementation "com.github.MFlisar.MaterialDialogFragments:dialogs-ads:<LATEST-VERSION>" // -------- // alternatively, to include ALL modules at once // -------- // implementation 'com.github.MFlisar:MaterialDialogFragments:<LATEST-VERSION>'
}

use

It’s very easy to use, all you have to do is:

  • Activities or Fragments The simple must be implemented with the dialogue fragments DialogFragmentCallback Interface:

     interface DialogFragmentCallback { fun onDialogResultAvailable(event: BaseDialogEvent): Boolean }
  • You create a dialog with the appropriate setup class such as

     DialogInfo( 1, "Info Title".asText(), "Some info label".asText() ) .create() .show(this)
  • by doing DialogFragmentCallback You can now handle the result as follows:

     override fun onDialogResultAvailable(event: BaseDialogEvent): Boolean { return when (event) { is DialogInfoEvent -> { Toast.makeText(this, "Info dialog closed - ID = ${event.id}", Toast.LENGTH_SHORT).show() true } else false } }

That’s all. Optionally, you can make some global settings such as the following, preferably only once in your application class:

DialogSetup.SEND_CANCEL_EVENT_BY_DEFAULT = true

The DialogSetup offers several other settings as well.

Check the demo app for more information.

Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox