Convert Figma logo to code with AI

orhanobut logodialogplus

Advanced dialog solution for android

5,001
793
5,001
54

Top Related Projects

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

SweetAlert for Android, a beautiful and clever alert dialog

Nifty Modal Dialog Effects

An Android Dialog Lib simplify customization.

Android下打造通用便捷的PopupWindow弹窗库

Quick Overview

DialogPlus is an Android library that provides an advanced dialog solution for creating custom dialogs with enhanced features. It offers a flexible and customizable way to display dialogs, bottom sheets, and popup windows in Android applications.

Pros

  • Easy to use and integrate into existing Android projects
  • Highly customizable with various animation options and content types
  • Supports both basic and complex dialog layouts
  • Lightweight and efficient, with minimal impact on app performance

Cons

  • Limited documentation and examples for advanced use cases
  • May require additional styling effort to match specific design requirements
  • Not actively maintained, with the last update being several years ago
  • Some reported issues with compatibility on newer Android versions

Code Examples

Creating a basic dialog:

DialogPlus.newDialog(context)
    .setContentHolder(ViewHolder(R.layout.dialog_content))
    .setExpanded(true)
    .create()
    .show()

Displaying a dialog as a bottom sheet:

DialogPlus.newDialog(context)
    .setContentHolder(ViewHolder(R.layout.dialog_content))
    .setGravity(Gravity.BOTTOM)
    .setExpanded(false)
    .create()
    .show()

Using a custom adapter for list-style dialogs:

val adapter = SimpleAdapter(context, items, R.layout.item_layout)
DialogPlus.newDialog(context)
    .setAdapter(adapter)
    .setOnItemClickListener { dialog, item, view, position ->
        // Handle item click
    }
    .create()
    .show()

Getting Started

  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.orhanobut:dialogplus:1.11@aar'
}
  1. Create a basic dialog in your activity or fragment:
import com.orhanobut.dialogplus.DialogPlus
import com.orhanobut.dialogplus.ViewHolder

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val dialog = DialogPlus.newDialog(this)
            .setContentHolder(ViewHolder(R.layout.dialog_content))
            .setExpanded(true)
            .create()

        findViewById<Button>(R.id.showDialogButton).setOnClickListener {
            dialog.show()
        }
    }
}

Competitor Comparisons

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

Pros of material-dialogs

  • More comprehensive and feature-rich, offering a wider range of dialog types and customization options
  • Follows Material Design guidelines more closely, providing a more modern and consistent look
  • Actively maintained with frequent updates and bug fixes

Cons of material-dialogs

  • Larger library size, which may impact app size and performance
  • Steeper learning curve due to its extensive API and features
  • May require more setup and configuration for basic use cases

Code Comparison

DialogPlus:

DialogPlus.newDialog(context)
    .setContentHolder(ViewHolder(R.layout.custom_dialog))
    .setExpanded(true)
    .create()
    .show()

material-dialogs:

MaterialDialog(this).show {
    title(R.string.dialog_title)
    message(R.string.dialog_message)
    positiveButton(R.string.agree)
    negativeButton(R.string.disagree)
}

Summary

DialogPlus is a lightweight and simple dialog library, ideal for basic use cases and smaller projects. It offers easy customization but with fewer built-in features.

material-dialogs provides a more comprehensive solution with extensive customization options and adherence to Material Design principles. It's better suited for larger projects requiring diverse dialog types and consistent styling across the app.

Choose DialogPlus for simplicity and small footprint, or material-dialogs for feature-rich, Material Design-compliant dialogs in more complex applications.

SweetAlert for Android, a beautiful and clever alert dialog

Pros of sweet-alert-dialog

  • More visually appealing and customizable dialog designs
  • Supports progress indicators and loading animations
  • Easier to create complex dialog sequences with chaining

Cons of sweet-alert-dialog

  • Larger library size, potentially impacting app performance
  • Less flexible positioning options compared to DialogPlus
  • May require more setup and configuration for basic use cases

Code Comparison

sweet-alert-dialog:

new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
    .setTitleText("Are you sure?")
    .setContentText("Won't be able to recover this file!")
    .setConfirmText("Yes, delete it!")
    .setConfirmClickListener(sDialog -> sDialog.dismissWithAnimation())
    .show();

DialogPlus:

DialogPlus dialog = DialogPlus.newDialog(this)
    .setContentHolder(new ViewHolder(R.layout.content))
    .setExpanded(true)
    .create();
dialog.show();

sweet-alert-dialog offers more built-in styling options and dialog types, while DialogPlus provides a simpler API for basic dialog creation. sweet-alert-dialog excels in creating visually rich alerts, while DialogPlus focuses on flexibility and ease of use for custom layouts. The choice between the two depends on the specific requirements of your project, balancing between aesthetic appeal and simplicity of implementation.

Nifty Modal Dialog Effects

Pros of NiftyDialogEffects

  • Offers a wide variety of animated dialog effects (14 different animations)
  • Provides visually appealing and engaging user interactions
  • Easy to customize and extend with new effects

Cons of NiftyDialogEffects

  • Less actively maintained (last update in 2015)
  • Limited configuration options compared to DialogPlus
  • Focuses primarily on visual effects rather than functional versatility

Code Comparison

NiftyDialogEffects:

NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(this);
dialogBuilder
    .withTitle("Title")
    .withMessage("Message")
    .withEffect(Effectstype.Slidetop)
    .withButton1Text("OK")
    .show();

DialogPlus:

DialogPlus dialog = DialogPlus.newDialog(this)
    .setContentHolder(new ViewHolder(R.layout.content))
    .setExpanded(true)
    .create();
dialog.show();

Summary

NiftyDialogEffects excels in providing visually striking dialog animations, making it suitable for apps that prioritize user engagement through eye-catching effects. However, it lacks recent updates and offers fewer customization options.

DialogPlus, on the other hand, focuses on functional versatility and ease of use. It provides more configuration options and is actively maintained, making it a better choice for developers who need a flexible and up-to-date dialog solution.

Choose NiftyDialogEffects for impressive visual effects, or DialogPlus for a more robust and customizable dialog implementation.

An Android Dialog Lib simplify customization.

Pros of FlycoDialog_Master

  • Offers a wider variety of dialog types, including custom dialogs and popup windows
  • Provides more customization options for dialog appearance and animations
  • Includes built-in material design support

Cons of FlycoDialog_Master

  • Less actively maintained, with the last update being several years ago
  • Documentation is primarily in Chinese, which may be challenging for non-Chinese speakers
  • Slightly more complex implementation due to increased customization options

Code Comparison

DialogPlus:

new DialogPlus.Builder(this)
    .setContentHolder(new ViewHolder(R.layout.content))
    .setExpanded(true)
    .create()
    .show();

FlycoDialog_Master:

new MaterialDialog.Builder(this)
    .title("Title")
    .content("Content")
    .positiveText("Agree")
    .negativeText("Disagree")
    .show();

Both libraries aim to simplify dialog creation in Android applications. DialogPlus focuses on simplicity and ease of use, while FlycoDialog_Master offers more extensive customization options and dialog types. The choice between the two depends on the specific requirements of your project and the level of customization needed.

Android下打造通用便捷的PopupWindow弹窗库

Pros of BasePopup

  • More comprehensive and feature-rich, offering a wider range of customization options
  • Better support for complex layouts and animations
  • Actively maintained with frequent updates and improvements

Cons of BasePopup

  • Steeper learning curve due to its extensive feature set
  • Larger library size, which may impact app size and performance

Code Comparison

DialogPlus:

new DialogPlus.Builder(this)
    .setContentHolder(new ViewHolder(R.layout.content))
    .setExpanded(true)
    .create()
    .show();

BasePopup:

new BasePopupWindow(this)
    .setContentView(R.layout.content)
    .setAnimationStyle(R.style.PopupAnimation)
    .setOutSideTouchable(true)
    .setBackgroundDimEnable(true)
    .showPopupWindow();

Summary

BasePopup offers more advanced features and customization options compared to DialogPlus, making it suitable for complex popup requirements. However, this comes at the cost of a steeper learning curve and potentially larger library size. DialogPlus, on the other hand, provides a simpler and more straightforward approach for basic popup needs. The choice between the two depends on the specific requirements of your project and the level of customization needed.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Android Arsenal API Join the chat at https://gitter.im/orhanobut/dialogplus

DialogPlus

Simple and advanced dialog solution.

  • Uses normal view as dialog
  • Provides expandable option
  • Multiple positioning
  • Built-in options for easy implementation

DialogPlus provides android L dialog animation
DialogPlus provides 3 position:
  • Top : Dialog will appear at top with animation
  • Center : Dialog will appear in the center with animation
  • Bottom : Dialog will appear at the bottom of the screen with animation
DialogPlus provides 3 content types:
  • ListHolder : Items will be shown in a listview
  • GridHolder : Items will be shown in a gridview
  • ViewHolder : Your customized view will be shown in the content

Gradle

implementation 'com.orhanobut:dialogplus:1.11@aar'

Usage

Use the builder to create the dialog.

Basic usage

DialogPlus dialog = DialogPlus.newDialog(this)
  .setAdapter(adapter)
  .setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(DialogPlus dialog, Object item, View view, int position) {
    }
  })
  .setExpanded(true)  // This will enable the expand feature, (similar to android L share dialog)
  .create();
dialog.show();

More options

Enable expand animation same as Android L share dialog

.setExpanded(true) // default is false, only works for grid and list

Set expand animation default height

.setExpanded(true, 300)

Select different holder.

  • Use ListView as content holder, note that this is default content type.
setContentHolder(new ListHolder())
  • Use ViewHolder as content holder if you want to use a custom view for your dialog. Pass resource id
.setContentHolder(new ViewHolder(R.layout.content))

or pass view itself

.setContentHolder(new ViewHolder(view))
  • Use GridHolder if you want to use GridView for the dialog. You must set column number.
.setContentHolder(new GridHolder(COLUMN_NUMBER))
  • Get the holder view, ListView, GridView or your custom view
View view = dialogPlus.getHolderView();
  • Set dialog position. BOTTOM (default), TOP or CENTER. You can also combine other Gravity options.
.setGravity(Gravity.CENTER)
  • Define if the dialog is cancelable and should be closed when back pressed or out of dialog is clicked
.setCancelable(true)
  • Set Adapter, this adapter will be used to fill the content for ListHolder and GridHolder. This is required if the content holder is ListHolder or GridHolder. It is not required if the content holder is ViewHolder.
.setAdapter(adapter);
  • Set an item click listener when list or grid holder is chosen. In that way you can have callbacks when one of your items is clicked
.setOnItemClickListener(new OnItemClickListener() {
  @Override
  public void onItemClick(DialogPlus dialog, Object item, View view, int position) {
  }
})
  • Set a global click listener to you dialog in order to handle all the possible click events. You can then identify the view by using its id and handle the correct behaviour. Only views which has id will trigger this event.
.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(DialogPlus dialog, View view) {

    }
})
  • Add margins to your dialog. They are set to 0 except when gravity is center. In that case basic margins are applied
.setMargin(left, top, right, bottom)
  • Set padding to the holder
.setPadding(left, top, right, bottom)
  • Set the footer view using the id of the layout resource
.setFooter(R.layout.footer)

or use view

.setFooter(view)
  • Get the footer view
View view = dialogPlus.getFooterView();
  • Set the header view using the id of the layout resource
.setHeader(R.layout.header)

or use view

.setHeader(view)
  • Get the header view
View view = dialogPlus.getHeaderView();
  • Set animation resources
.setInAnimation(R.anim.abc_fade_in)
.setOutAnimation(R.anim.abc_fade_out)
  • Set width and height for the content
.setContentWidth(ViewGroup.LayoutParams.WRAP_CONTENT)  // or any custom width ie: 300
.setContentHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
  • Dismiss Listener, triggered when the dialog is dismissed
.setOnDismissListener(new OnDismissListener() {
    @Override
    public void onDismiss(DialogPlus dialog) {

    }
})
  • Cancel Listener, triggered when the dialog is cancelled by back button or clicking outside
.setOnCancelListener(new OnCancelListener() {
    @Override
    public void onCancel(DialogPlus dialog) {

    }
})
  • BackPress Listener, triggered when the back button is pressed
.setOnBackPressListener(new OnBackPressListener() {
    @Override
    public void onBackPressed(DialogPlus dialog) {

    }
})
  • Change content container background, as default white
.setContentBackgroundResource(resource)
  • Change overlay container background, as default it's semi-transparent black
.setOverlayBackgroundResource(resource)

License

Copyright 2016 Orhan Obut

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.