Code Monkey home page Code Monkey logo

light-dialog's Introduction

Light-Dialog

Android component dialog with buttons for easy action implementations in it yours buttons

Why would i use this?

If you are tired of create a big codes and stay think in how to create yours popup messages, we have a solution for your project

Ok, i want test this

Right, the first step is add this lib a your dependency and configure your project:

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency:

dependencies {
        implementation 'com.github.michel566:Light-Dialog:0.11'
}

In moment of write this, this release is 0.11.

And, yes. I copy this explaination of the Jitpack... :).

Step 3. Add the object for the event of onClick:

JAVA EXAMPLE:

    Button btNoOptions = findViewById(R.id.bt_noOptions);
    final LightDialog infoDialog = new LightDialog(this, "This is a info dialog, with no option button", DialogType.INFO);
    btNoOptions.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            infoDialog.show();
        }
    });

KOTLIN EXAMPLE:

    val infoDialog = LightDialog(this, "This is a info dialog, with no option button", DialogType.INFO)
    bt_noOptions.setOnClickListener {
        infoDialog.show()
    }

Customize your dialog

Lightdialog provides support for up to two buttons, to be able to insert them in your dialog, it is necessary to call the objects of the dialogs the following methods:

One button

JAVA EXAMPLE:

    alertDialog.onOptionConfirmClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
            alertDialog.dismiss();
    	    Toast.makeText(MainActivity.this, "Confirm!", Toast.LENGTH_SHORT).show();
    	}
}, "OK");

KOTLIN EXAMPLE:

alertDialog.onOptionConfirmClickListener(
            {
                alertDialog.dismiss()
                Toast.makeText(this, "Confirm!", Toast.LENGTH_SHORT).show()
            }, "OK"
        )

Two buttons

JAVA EXAMPLE:

            errorDialog.onOptionConfirmClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    errorDialog.dismiss();
                    Toast.makeText(MainActivity.this, "Confirm!", Toast.LENGTH_SHORT).show();

                }
            }, "OK");

            errorDialog.onOptionEscapeClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    errorDialog.dismiss();
                    Toast.makeText(MainActivity.this, "Negate!", Toast.LENGTH_SHORT).show();
                }
            }, "NO");

KOTLIN EXAMPLE:

    errorDialog.onOptionConfirmClickListener(
            {
                errorDialog.dismiss()
                Toast.makeText(this, "Confirm!", Toast.LENGTH_SHORT).show()
            }, "OK"
        )

        errorDialog.onOptionEscapeClickListener(
            {
                errorDialog.dismiss()
                Toast.makeText(this, "Escape!", Toast.LENGTH_SHORT).show()
            }, "NO"
        )
    }

Dialog types

We use a default style in the dialog, a clean style to attendance to major cases, but we want in future releases, give you the opportunity to create your own layout, and insert it into our lib. But in any case, you are free to copy my project and adapt it to your greatest need, as long as it meets the requirements of the GNU.

We have a three default dialog types with three levels of criticality of this application, what you can call it through DialogType enum:

  • DialogType.INFO (Light blue)
  • DialogType.ALERT (Yellow)
  • DialogType.ERROR (Red)

Extras

isCanceledOnTouchOutside

When you instantiate your dialog, you can set a last param of constructor with true and false, true is default, but false lock the current screen of context until the next event of dismiss to event click of your dialog button.

light-dialog's People

Contributors

michel566 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.