Skip to content

Commit 728629d

Browse files
committed
Added error, ok, info with Iconify
1 parent ec7eb25 commit 728629d

File tree

2 files changed

+54
-19
lines changed

2 files changed

+54
-19
lines changed

.idea/workspace.xml

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/github/pierry/simpletoast/SimpleToast.java

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ public static void ok(Context context, String msg) {
5252
mytoast.show();
5353
}
5454

55-
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void ok(Context context, String msg, int color, int borderColor,
56-
Iconify.IconValue iconValue) {
55+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void ok(Context context, String msg, Iconify.IconValue iconValue) {
5756
LayoutInflater myInflater = LayoutInflater.from(context);
5857
View view = myInflater.inflate(R.layout.toast_base, null);
5958

@@ -62,7 +61,7 @@ public static void ok(Context context, String msg) {
6261

6362
IconTextView img = (IconTextView) view.findViewById(R.id.img);
6463
img.setBackground(new IconDrawable(context, iconValue)
65-
.colorRes(R.color.white).sizeDp(40));
64+
.colorRes(R.color.white).sizeDp(30));
6665

6766
Toast mytoast = new Toast(context);
6867

@@ -85,6 +84,24 @@ public static void error(Context context, String msg) {
8584
mytoast.show();
8685
}
8786

87+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void error(Context context, String msg, Iconify.IconValue iconValue) {
88+
LayoutInflater myInflater = LayoutInflater.from(context);
89+
View view = myInflater.inflate(R.layout.toast_error, null);
90+
91+
Button button = (Button) view.findViewById(R.id.button);
92+
button.setText(msg);
93+
94+
IconTextView img = (IconTextView) view.findViewById(R.id.img);
95+
img.setBackground(new IconDrawable(context, iconValue)
96+
.colorRes(R.color.white).sizeDp(30));
97+
98+
Toast mytoast = new Toast(context);
99+
100+
mytoast.setView(view);
101+
mytoast.setDuration(Toast.LENGTH_SHORT);
102+
mytoast.show();
103+
}
104+
88105
public static void info(Context context, String msg) {
89106
LayoutInflater myInflater = LayoutInflater.from(context);
90107
View view = myInflater.inflate(R.layout.toast_info, null);
@@ -99,6 +116,24 @@ public static void info(Context context, String msg) {
99116
mytoast.show();
100117
}
101118

119+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void info(Context context, String msg, Iconify.IconValue iconValue) {
120+
LayoutInflater myInflater = LayoutInflater.from(context);
121+
View view = myInflater.inflate(R.layout.toast_info, null);
122+
123+
Button button = (Button) view.findViewById(R.id.button);
124+
button.setText(msg);
125+
126+
IconTextView img = (IconTextView) view.findViewById(R.id.img);
127+
img.setBackground(new IconDrawable(context, iconValue)
128+
.colorRes(R.color.white).sizeDp(30));
129+
130+
Toast mytoast = new Toast(context);
131+
132+
mytoast.setView(view);
133+
mytoast.setDuration(Toast.LENGTH_SHORT);
134+
mytoast.show();
135+
}
136+
102137
private static Button getButtonInstance() {
103138
mButton = (Button) mView.findViewById(R.id.button);
104139
return mButton;

0 commit comments

Comments
 (0)