Skip to content

Commit b87af14

Browse files
pierryborgespierryborges
pierryborges
authored and
pierryborges
committed
Added time control
1 parent eeb0dcd commit b87af14

File tree

7 files changed

+559
-469
lines changed

7 files changed

+559
-469
lines changed

.idea/gradle.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+434-426
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/app.iml

+20-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="simpletoast" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="SimpleToast" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="android-gradle" name="Android-Gradle">
55
<configuration>
@@ -12,10 +12,7 @@
1212
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
1313
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
1414
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
15-
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
16-
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
1715
<afterSyncTasks>
18-
<task>generateDebugAndroidTestSources</task>
1916
<task>generateDebugSources</task>
2017
</afterSyncTasks>
2118
<option name="ALLOW_USER_CONFIGURATION" value="false" />
@@ -29,7 +26,7 @@
2926
</component>
3027
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
3128
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
32-
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
29+
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
3330
<exclude-output />
3431
<content url="file://$MODULE_DIR$">
3532
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
@@ -51,37 +48,45 @@
5148
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
5249
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
5350
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
51+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
52+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
53+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
54+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
55+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
56+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/jni" isTestSource="true" />
57+
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
5458
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
5559
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
5660
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
5761
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
5862
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
5963
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
6064
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
65+
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
66+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
67+
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
68+
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
69+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
70+
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
71+
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
6172
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
6273
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
6374
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
6475
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
6576
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
6677
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
6778
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
79+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
6880
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
6981
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
7082
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
71-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
7283
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
73-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
74-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
7584
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
76-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
77-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
78-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
7985
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
8086
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
81-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
82-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
83-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
87+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/mockable-android-21.jar" />
8488
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
89+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
8590
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
8691
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
8792
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
@@ -92,6 +97,7 @@
9297
<orderEntry type="library" exported="" name="android-iconify-1.0.9" level="project" />
9398
<orderEntry type="library" exported="" name="support-v4-22.1.0" level="project" />
9499
<orderEntry type="library" exported="" name="support-annotations-22.1.0" level="project" />
100+
<orderEntry type="library" exported="" scope="TEST" name="mockable-android-21" level="project" />
95101
<orderEntry type="library" exported="" name="appcompat-v7-22.1.0" level="project" />
96102
</component>
97103
</module>

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

+94-25
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.annotation.TargetApi;
44
import android.content.Context;
55
import android.os.Build;
6+
import android.os.Handler;
67
import android.view.LayoutInflater;
78
import android.view.View;
89
import android.widget.Button;
@@ -54,6 +55,31 @@ public static void ok(Context context, String msg) {
5455
mToast.show();
5556
}
5657

58+
public static void ok(Context context, String msg, String icon, int time){
59+
mInflater = LayoutInflater.from(context);
60+
if (!icon.equals("")) {
61+
mView = mInflater.inflate(R.layout.toast_ok_icon, null);
62+
IconTextView img = (IconTextView) mView.findViewById(R.id.img);
63+
img.setText(icon);
64+
img.setTextSize(20);
65+
} else {
66+
mView = mInflater.inflate(R.layout.toast_ok, null);
67+
}
68+
initSetButtonMsg(msg);
69+
mToast = new Toast(context);
70+
mToast.setView(mView);
71+
mToast.setDuration(Toast.LENGTH_SHORT);
72+
mToast.show();
73+
if (time != 0) {
74+
Handler handler = new Handler();
75+
handler.postDelayed(new Runnable() {
76+
@Override public void run() {
77+
mToast.cancel();
78+
}
79+
}, time);
80+
}
81+
}
82+
5783
public static void error(Context context, String msg) {
5884
mInflater = LayoutInflater.from(context);
5985
mView = mInflater.inflate(R.layout.toast_error, null);
@@ -64,18 +90,29 @@ public static void error(Context context, String msg) {
6490
mToast.show();
6591
}
6692

67-
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void error(Context context, String msg,
68-
String icon) {
93+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void error(Context context, String msg, String icon, int time){
6994
mInflater = LayoutInflater.from(context);
70-
mView = mInflater.inflate(R.layout.toast_error_icon, null);
95+
if (!icon.equals("")) {
96+
mView = mInflater.inflate(R.layout.toast_error_icon, null);
97+
IconTextView img = (IconTextView) mView.findViewById(R.id.img);
98+
img.setText(icon);
99+
img.setTextSize(20);
100+
} else {
101+
mView = mInflater.inflate(R.layout.toast_error, null);
102+
}
71103
initSetButtonMsg(msg);
72-
IconTextView img = (IconTextView) mView.findViewById(R.id.img);
73-
img.setText(icon);
74-
img.setTextSize(20);
75104
mToast = new Toast(context);
76105
mToast.setView(mView);
77106
mToast.setDuration(Toast.LENGTH_SHORT);
78107
mToast.show();
108+
if (time != 0) {
109+
Handler handler = new Handler();
110+
handler.postDelayed(new Runnable() {
111+
@Override public void run() {
112+
mToast.cancel();
113+
}
114+
}, time);
115+
}
79116
}
80117

81118
public static void info(Context context, String msg) {
@@ -88,19 +125,29 @@ public static void info(Context context, String msg) {
88125
mToast.show();
89126
}
90127

91-
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void info(Context context, String msg,
92-
String icon) {
128+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void info(Context context, String msg, String icon, int time){
93129
mInflater = LayoutInflater.from(context);
94-
mView = mInflater.inflate(R.layout.toast_info_icon, null);
130+
if (!icon.equals("")) {
131+
mView = mInflater.inflate(R.layout.toast_info_icon, null);
132+
IconTextView img = (IconTextView) mView.findViewById(R.id.img);
133+
img.setText(icon);
134+
img.setTextSize(20);
135+
} else {
136+
mView = mInflater.inflate(R.layout.toast_info, null);
137+
}
95138
initSetButtonMsg(msg);
96-
;
97-
IconTextView img = (IconTextView) mView.findViewById(R.id.img);
98-
img.setText(icon);
99-
img.setTextSize(20);
100139
mToast = new Toast(context);
101140
mToast.setView(mView);
102141
mToast.setDuration(Toast.LENGTH_SHORT);
103142
mToast.show();
143+
if (time != 0) {
144+
Handler handler = new Handler();
145+
handler.postDelayed(new Runnable() {
146+
@Override public void run() {
147+
mToast.cancel();
148+
}
149+
}, time);
150+
}
104151
}
105152

106153
public static void muted(Context context, String msg) {
@@ -113,18 +160,29 @@ public static void muted(Context context, String msg) {
113160
mToast.show();
114161
}
115162

116-
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void muted(Context context, String msg,
117-
String icon) {
163+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void muted(Context context, String msg, String icon, int time){
118164
mInflater = LayoutInflater.from(context);
119-
mView = mInflater.inflate(R.layout.toast_muted_icon, null);
165+
if (!icon.equals("")) {
166+
mView = mInflater.inflate(R.layout.toast_muted_icon, null);
167+
IconTextView img = (IconTextView) mView.findViewById(R.id.img);
168+
img.setText(icon);
169+
img.setTextSize(20);
170+
} else {
171+
mView = mInflater.inflate(R.layout.toast_muted, null);
172+
}
120173
initSetButtonMsg(msg);
121-
IconTextView img = (IconTextView) mView.findViewById(R.id.img);
122-
img.setText(icon);
123-
img.setTextSize(20);
124174
mToast = new Toast(context);
125175
mToast.setView(mView);
126176
mToast.setDuration(Toast.LENGTH_SHORT);
127177
mToast.show();
178+
if (time != 0) {
179+
Handler handler = new Handler();
180+
handler.postDelayed(new Runnable() {
181+
@Override public void run() {
182+
mToast.cancel();
183+
}
184+
}, time);
185+
}
128186
}
129187

130188
public static void warning(Context context, String msg) {
@@ -137,18 +195,29 @@ public static void warning(Context context, String msg) {
137195
mToast.show();
138196
}
139197

140-
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void warning(Context context, String msg,
141-
String icon) {
198+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void warning(Context context, String msg, String icon, int time){
142199
mInflater = LayoutInflater.from(context);
143-
mView = mInflater.inflate(R.layout.toast_warning_icon, null);
200+
if (!icon.equals("")) {
201+
mView = mInflater.inflate(R.layout.toast_warning_icon, null);
202+
IconTextView img = (IconTextView) mView.findViewById(R.id.img);
203+
img.setText(icon);
204+
img.setTextSize(20);
205+
} else {
206+
mView = mInflater.inflate(R.layout.toast_warning, null);
207+
}
144208
initSetButtonMsg(msg);
145-
IconTextView img = (IconTextView) mView.findViewById(R.id.img);
146-
img.setText(icon);
147-
img.setTextSize(20);
148209
mToast = new Toast(context);
149210
mToast.setView(mView);
150211
mToast.setDuration(Toast.LENGTH_SHORT);
151212
mToast.show();
213+
if (time != 0) {
214+
Handler handler = new Handler();
215+
handler.postDelayed(new Runnable() {
216+
@Override public void run() {
217+
mToast.cancel();
218+
}
219+
}, time);
220+
}
152221
}
153222

154223
private static Button initSetButtonMsg(String msg) {
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Apr 10 15:27:10 PDT 2013
1+
#Mon Feb 01 11:10:01 BRST 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip

simpletoast.iml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id="simpletoast" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id="SimpleToast" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
33
<component name="FacetManager">
44
<facet type="java-gradle" name="Java-Gradle">
55
<configuration>

0 commit comments

Comments
 (0)