Skip to content

Commit dc8fc51

Browse files
committed
Documentations Updated
1 parent 1b0f053 commit dc8fc51

File tree

5 files changed

+42
-41
lines changed

5 files changed

+42
-41
lines changed

README.md

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ allprojects {
3434
> **Step 2.** Add the dependency:
3535
```gradle
3636
dependencies {
37-
implementation 'com.github.smith8h:SToast:2.0'
37+
implementation 'com.github.smith8h:SToast:2.5'
3838
}
3939
```
4040

@@ -48,22 +48,26 @@ dependencies {
4848
<img src="https://te.legra.ph/file/3383a5c2ea7b770e257f1.jpg" style="width: 80%;"/>
4949
</p>
5050

51-
Create new Adaptive SToast:
52-
- `new SToast.Adaptive(context, SToast.SHORT)` the constructor accepts a context and duration.
53-
You can use `SToast.LONG` for longer duration.
54-
Available methods:
55-
- `setIconAndColor(...)` accepting **resource drawable/mipmap** for icon, and **int color** (you can use **Color.NAME** or from resources **getColor(R.color.name)**).
56-
- `setTitle("title")` to set the title of toast.
57-
- `setText("some text")` to set the message for the user.
58-
- `show()` to show the SToast.
59-
<br/>
51+
Create Adaptive SToast:
52+
- `AdaptiveSToast.with(context)` pass a context.
53+
- `.duration(AdaptiveSToast.LENGTH_LONG)` or `LENGTH_SHORT` (Optional | Default is short).
54+
- `.icon(iconIntRes, colorInt)` **int resource drawable** for icon, and **int|String color** for icon color (Optional).
55+
- `.title("title")` to set the title of toast.
56+
- `.text("some text")` to set the message for the user.
57+
- `.show()` to show the SToast.
6058

61-
> Full Code Example
59+
Final code:
6260
```java
63-
new SToast.Adaptive(this, SToast.LONG)
64-
.setIconAndColor(R.drawable.ok_img)
65-
.setTitle("All Ok!")
66-
.setText("Scanning process completed.")
61+
AdaptiveSToast.with(this)
62+
.title("title")
63+
.text("text")
64+
65+
/* for customization
66+
.icon(R.drawable.icon, getColor(R.color.color)) // or ↓
67+
OR .icon(R.drawable.icon, "hex color")
68+
.duration(AdaptiveSToast.LENGTH_LONG)
69+
*/
70+
6771
.show();
6872
```
6973

@@ -77,33 +81,27 @@ This is DONE mode
7781
</p>
7882

7983
Create new Mode SToast:
80-
- `new SToast.Mode(context, SToast.SHORT)` the constructor accepts a context and duration.
81-
You can use `SToast.LONG` for longer duration.
82-
Available methods:
83-
- `setMode(...)` to set the mode you can use
84-
- **SToast.MODE_OK**
85-
- **SToast.MODE_DONE**
86-
- **SToast.MODE_WARN**
87-
- **SToast.MODE_ERROR**
88-
- **SToast.MODE_CONFUSE**
89-
- **SToast.MODE_INFO**
90-
- **SToast.MODE_HEART**
91-
- `setTitle("title")` to set the title of toast.
92-
- `setText("some text")` to set the message for the user.
84+
- `ModeSToast.with(context)` pass a context.
85+
- `.mode(...)` to set the mode you can use **ModeSToast.MODE_OK**, **MODE_DONE**, **MODE_WARN**,- **MODE_ERROR**, **MODE_CONFUSE**, **MODE_INFO**, **MODE_HEART**
86+
- `.duration(ModeSToast.LENGTH_LONG)` or `LENGTH_SHORT` (Optional | Default is short).
87+
- `.title("title")` to set the title of toast.
88+
- `.text("some text")` to set the message for the user.
9389
- `show()` to show the SToast.
90+
9491
<br/>
9592

96-
> Full Code Example
93+
Final Code:
9794
```java
98-
new SToast.Mode(this, SToast.LONG)
99-
.setMode(SToast.MODE_HEART)
100-
.setTitle("Big Love!")
101-
.setText("Thanks for your donation.")
95+
ModeSToast(this)
96+
.mode(ModeSToast.MODE_HEART)
97+
.title("Big Love!")
98+
.text("Thanks for your donation.")
10299
.show();
103100
```
104101

105102
# Usable Resources 🗄
106-
You can use the drawable resources of this lib in your app!<br>
103+
You can use the drawables of this lib in your app!<br>
104+
import smith.lib.alerts.toast.R and use them
107105
`ok_img`, `true_img`, `false_img`, `warn_img`, `info_img`, `confuse_img`, `heart_img`
108106
<br/>
109107

SToast/src/main/java/smith/lib/alerts/toast/AdaptiveSToast.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class AdaptiveSToast {
2020
private Context context;
2121
private String titleTxt, textTxt;
2222
private int color = 0xFFFF5252;
23-
private int icon = R.drawable.heart_img;
23+
private int icon = R.drawable.default_img;
2424
private int duration = LENGTH_SHORT;
2525

2626
public static AdaptiveSToast with(Context ctx) {
@@ -40,19 +40,19 @@ public AdaptiveSToast title(String title) {
4040
}
4141

4242
public AdaptiveSToast text(String text) {
43-
text = text;
43+
this.textTxt = text;
4444
return this;
4545
}
4646

4747
public AdaptiveSToast icon(int icon, int iconColor) {
48-
icon = icon;
49-
color = iconColor;
48+
this.icon = icon;
49+
this.color = iconColor;
5050
return this;
5151
}
5252

5353
public AdaptiveSToast icon(int icon, String iconColor) {
54-
icon = icon;
55-
color = Color.parseColor(iconColor);
54+
this.icon = icon;
55+
this.color = Color.parseColor(iconColor);
5656
return this;
5757
}
5858

app/src/main/java/smith/test/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected void onCreate(Bundle savedInstanceState) {
1616
public void show(View v) {
1717
AdaptiveSToast.with(this)
1818
.duration(AdaptiveSToast.LENGTH_SHORT)
19-
.icon(R.drawable.heart_img, getColor(R.color.acc))
19+
.icon(smith.lib.alerts.toast.R.drawable.heart_img, getColor(R.color.acc))
2020
.title("Big Love!")
2121
.text("This is Night Mode Adaptive SToast.")
2222
.show();

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ buildscript {
1111
maven { url 'https://repo.maven.apache.org/maven2' }
1212
maven { url 'https://jcenter.bintray.com' }
1313
maven { url 'https://dl.google.com' }
14+
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
1415
}
1516
}
1617

@@ -31,6 +32,7 @@ allprojects {
3132
maven { url 'https://repo.maven.apache.org/maven2' }
3233
maven { url 'https://jcenter.bintray.com' }
3334
maven { url 'https://dl.google.com' }
35+
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
3436
}
3537
}
3638

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencyResolutionManagement {
1818
maven { url 'https://repo.maven.apache.org/maven2' }
1919
maven { url 'https://jcenter.bintray.com' }
2020
maven { url 'https://dl.google.com' }
21+
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
2122
}
2223
}
2324

0 commit comments

Comments
 (0)