Skip to content

Commit 4323135

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 9b43a63 + 6d0318d commit 4323135

File tree

1 file changed

+139
-5
lines changed

1 file changed

+139
-5
lines changed

README.md

+139-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,153 @@
11
# Commons
22
Common android components, helper functions, adaptors, dialogs, logs and extentions functions that is required for almost every application at startup.
33

4-
## How to use
4+
## Modules
5+
1. [Dialogs](#Dialogs)
6+
7+
## Dialogs
8+
1. [Information Dialog](#Information-Dialog)
9+
2. [Warning Dialog](#Warning-Dialog)
10+
3. [Error Dialog](#Error-Dialog)
11+
4. [Delete Dialog](#Delete-Dialog)
12+
5. [Wait Dialog](#Wait-Dialog)
13+
6. [How to use](#How-to-use-dialogs)
14+
7. [Calling From Java](#Calling-from-Java)
15+
16+
### Information Dialog
17+
```kotlin
18+
infoDialog(
19+
this, // context
20+
"Information", // title
21+
"Some informational message", // message
22+
true // cancelable on back press or touch anywhere on the screen
23+
).show()
24+
```
25+
#### or
26+
```kotlin
27+
infoDialog(
28+
this, // context
29+
"Information", // title
30+
"Some informational message", // message
31+
true // cancelable on back press or touch anywhere on the screen
32+
).setPositiveButton("OK") { dialog, _ ->
33+
// Ok button action
34+
dialog.dismiss()
35+
}.setNegativeButton("Close") { dialog, _ ->
36+
// close button action
37+
dialog.dismiss()
38+
}.show()
39+
```
40+
41+
### Warning Dialog
42+
```kotlin
43+
warningDialog(
44+
this, // context
45+
"Warning", // title
46+
"Some warning message", // message
47+
true // cancelable on back press or touch anywhere on the screen
48+
).show()
49+
```
50+
#### or
51+
```kotlin
52+
warningDialog(
53+
this, // context
54+
"Warning", // title
55+
"Some warning message", // message
56+
true // cancelable on back press or touch anywhere on the screen
57+
).setPositiveButton("OK") { dialog, _ ->
58+
// Ok button action
59+
dialog.dismiss()
60+
}.setNegativeButton("Close") { dialog, _ ->
61+
// close button action
62+
dialog.dismiss()
63+
}.show()
64+
```
65+
66+
### Error Dialog
67+
```kotlin
68+
errorDialog(
69+
this, // context
70+
"Error", // title
71+
"Some error message", // message
72+
true // cancelable on back press or touch anywhere on the screen
73+
).show()
74+
```
75+
#### or
76+
```kotlin
77+
errorDialog(
78+
this, // context
79+
"Error", // title
80+
"Some error message", // message
81+
true // cancelable on back press or touch anywhere on the screen
82+
).setPositiveButton("OK") { dialog, _ ->
83+
// Ok button action
84+
dialog.dismiss()
85+
}.setNegativeButton("Close") { dialog, _ ->
86+
// close button action
87+
dialog.dismiss()
88+
}.show()
89+
```
90+
91+
### Delete Dialog
92+
```kotlin
93+
confirmDelete(
94+
this, // context
95+
"Confirm Delete", // title
96+
"Some confirmation message", // message
97+
true // cancelable on back press or touch anywhere on the screen
98+
).setPositiveButton("Delete") { dialog, _ ->
99+
// Ok button action
100+
dialog.dismiss()
101+
}.setNegativeButton("Close") { dialog, _ ->
102+
// close button action
103+
dialog.dismiss()
104+
}.show()
105+
.getButton(AlertDialog.BUTTON_POSITIVE)
106+
.setTextColor(ContextCompat.getColor(this, android.R.color.holo_red_light))
107+
```
108+
109+
### Wait Dialog
110+
```kotlin
111+
waitDialog(
112+
this, // context
113+
"Loading, Please wait...", // message
114+
true // cancelable on back press or touch anywhere on the screen
115+
).show()
116+
```
117+
118+
### How to use dialogs
119+
#### add this line to project `build.gradle` file
5120
```gradle
6121
allprojects {
7122
repositories {
8-
...
9123
maven { url 'https://jitpack.io' }
10124
}
11125
}
12126
```
13-
14-
### add this line to app `build.gradle` file
127+
#### add this line to app `build.gradle` file
15128
```gradle
16129
dependencies {
17-
implementation 'com.github.ArbazMateen:Commons:0.1.1'
130+
implementation 'com.github.ArbazMateen.Commons:dialogs:0.1.1'
18131
}
19132
```
133+
134+
### Calling from Java
135+
```java
136+
NotificationDialog.infoDialog(
137+
this,
138+
"Some informational message"
139+
).setPositiveButton("", new DialogInterface.OnClickListener() {
140+
@Override
141+
public void onClick(DialogInterface dialog, int which) {
142+
// positive button action
143+
dialog.dismiss();
144+
}
145+
}).setNegativeButton("Close", new DialogInterface.OnClickListener() {
146+
@Override
147+
public void onClick(DialogInterface dialog, int which) {
148+
// negative button action
149+
dialog.dismiss();
150+
}
151+
}).show();
152+
```
153+

0 commit comments

Comments
 (0)