Skip to content

Common android components, helper functions, adaptors, dialogs, logs and extentions functions that is required for almost every application at startup.

License

Notifications You must be signed in to change notification settings

Arbaz-Softagics/Commons-1

 
 

Repository files navigation

Commons

Common android components, helper functions, adaptors, dialogs, logs and extentions functions that is required for almost every application at startup.

Modules

  1. Dialogs
  2. Adaptors
  3. Extensions
  4. Preference
  5. Input Validator

Dialogs

  1. Information Dialog
  2. Warning Dialog
  3. Error Dialog
  4. Delete Dialog
  5. Wait Dialog
  6. How to use
  7. Calling From Java

Information Dialog

	infoDialog(
                this,   			// context
                "Information",  		// title
                "Some informational message",   // message
                true    			// cancelable on back press or touch anywhere on the screen
            ).show()

or

	infoDialog(
                this,   			// context
                "Information",  		// title
                "Some informational message",   // message
                true    			// cancelable on back press or touch anywhere on the screen
            ).setPositiveButton("OK") { dialog, _ ->
                // Ok button action
                dialog.dismiss()
            }.setNegativeButton("Close") { dialog, _ ->
                // close button action
                dialog.dismiss()
            }.show()

Warning Dialog

	warningDialog(
                this,   			// context
                "Warning",  			// title
                "Some warning message",   	// message
                true    			// cancelable on back press or touch anywhere on the screen
            ).show()

or

	warningDialog(
                this,   			// context
                "Warning",  			// title
                "Some warning message",   	// message
                true    			// cancelable on back press or touch anywhere on the screen
            ).setPositiveButton("OK") { dialog, _ ->
                // Ok button action
                dialog.dismiss()
            }.setNegativeButton("Close") { dialog, _ ->
                // close button action
                dialog.dismiss()
            }.show()

Error Dialog

	errorDialog(
                this,   			// context
                "Error",  			// title
                "Some error message",   	// message
                true    			// cancelable on back press or touch anywhere on the screen
            ).show()

or

	errorDialog(
                this,   			// context
                "Error",  			// title
                "Some error message",   	// message
                true    			// cancelable on back press or touch anywhere on the screen
            ).setPositiveButton("OK") { dialog, _ ->
                // Ok button action
                dialog.dismiss()
            }.setNegativeButton("Close") { dialog, _ ->
                // close button action
                dialog.dismiss()
            }.show()

Delete Dialog

	confirmDelete(
                this,   			// context
                "Confirm Delete",  		// title
                "Some confirmation message",   	// message
                true    			// cancelable on back press or touch anywhere on the screen
            ).setPositiveButton("Delete") { dialog, _ ->
                // Ok button action
                dialog.dismiss()
            }.setNegativeButton("Close") { dialog, _ ->
                // close button action
                dialog.dismiss()
            }.show()
            .getButton(AlertDialog.BUTTON_POSITIVE)
                .setTextColor(ContextCompat.getColor(this, android.R.color.holo_red_light))

Wait Dialog

	waitDialog(
                this,   			// context
                "Loading, Please wait...",  	// message
                true    			// cancelable on back press or touch anywhere on the screen
            ).show()

How to use dialogs

add this line to project build.gradle file

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

add this line to app build.gradle file

	dependencies {
	        implementation 'com.github.ArbazMateen.Commons:dialogs:0.1.2'
	}

Calling from Java

	Dialog.infoDialog(
                this,
                "Some informational message"
        ).setPositiveButton("", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // positive button action
                dialog.dismiss();
            }
        }).setNegativeButton("Close", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // negative button action
                dialog.dismiss();
            }
        }).show();

About

Common android components, helper functions, adaptors, dialogs, logs and extentions functions that is required for almost every application at startup.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 99.4%
  • Java 0.6%