-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
1 changed file
with
139 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,153 @@ | ||
# Commons | ||
Common android components, helper functions, adaptors, dialogs, logs and extentions functions that is required for almost every application at startup. | ||
|
||
## How to use | ||
## Modules | ||
1. [Dialogs](#Dialogs) | ||
|
||
## Dialogs | ||
1. [Information Dialog](#Information-Dialog) | ||
2. [Warning Dialog](#Warning-Dialog) | ||
3. [Error Dialog](#Error-Dialog) | ||
4. [Delete Dialog](#Delete-Dialog) | ||
5. [Wait Dialog](#Wait-Dialog) | ||
6. [How to use](#How-to-use-dialogs) | ||
7. [Calling From Java](#Calling-from-Java) | ||
|
||
### Information Dialog | ||
```kotlin | ||
infoDialog( | ||
this, // context | ||
"Information", // title | ||
"Some informational message", // message | ||
true // cancelable on back press or touch anywhere on the screen | ||
).show() | ||
``` | ||
#### or | ||
```kotlin | ||
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 | ||
```kotlin | ||
warningDialog( | ||
this, // context | ||
"Warning", // title | ||
"Some warning message", // message | ||
true // cancelable on back press or touch anywhere on the screen | ||
).show() | ||
``` | ||
#### or | ||
```kotlin | ||
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 | ||
```kotlin | ||
errorDialog( | ||
this, // context | ||
"Error", // title | ||
"Some error message", // message | ||
true // cancelable on back press or touch anywhere on the screen | ||
).show() | ||
``` | ||
#### or | ||
```kotlin | ||
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 | ||
```kotlin | ||
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 | ||
```kotlin | ||
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 | ||
```gradle | ||
allprojects { | ||
repositories { | ||
... | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
``` | ||
|
||
### add this line to app `build.gradle` file | ||
#### add this line to app `build.gradle` file | ||
```gradle | ||
dependencies { | ||
implementation 'com.github.ArbazMateen:Commons:0.1.1' | ||
implementation 'com.github.ArbazMateen.Commons:dialogs:0.1.1' | ||
} | ||
``` | ||
|
||
### Calling from Java | ||
```java | ||
NotificationDialog.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(); | ||
``` | ||
|