Skip to content

Commit b75eec3

Browse files
committed
see 09/02 log
1 parent 814491e commit b75eec3

File tree

14 files changed

+111
-196
lines changed

14 files changed

+111
-196
lines changed

README-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ getEntries : 获取压缩文件中的文件对象
616616

617617
Gradle:
618618
``` groovy
619-
compile 'com.blankj:utilcode:1.8.5'
619+
compile 'com.blankj:utilcode:1.8.6'
620620
```
621621

622622

@@ -639,7 +639,7 @@ Utils.init(context);
639639

640640
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
641641

642-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.8.5-brightgreen.svg
642+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.8.6-brightgreen.svg
643643
[auc]: https://github.com/Blankj/AndroidUtilCode
644644

645645
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,6 @@ getZodiac
575575
* ### About Toast→[ToastUtils.java][toast.java][Demo][toast.demo]
576576
```
577577
setGravity
578-
setView
579-
getView
580578
setBgColor
581579
setBgResource
582580
setMessageColor
@@ -618,7 +616,7 @@ getEntries
618616

619617
Gradle:
620618
``` groovy
621-
compile 'com.blankj:utilcode:1.8.5'
619+
compile 'com.blankj:utilcode:1.8.6'
622620
```
623621

624622

@@ -641,7 +639,7 @@ Utils.init(context);
641639

642640
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
643641

644-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.8.5-brightgreen.svg
642+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.8.6-brightgreen.svg
645643
[auc]: https://github.com/Blankj/AndroidUtilCode
646644

647645
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

app/src/main/java/com/blankj/androidutilcode/core/toast/CustomToast.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* desc :
1616
* </pre>
1717
*/
18-
public class MyToast {
18+
public class CustomToast {
1919

20-
public static void showMyToast(@NonNull final String message){
20+
public static void show(@NonNull final String message){
2121
View toastView = ToastUtils.showCustomLongSafe(R.layout.toast_custom);
2222
TextView tvMessage = (TextView) toastView.findViewById(R.id.tv_toast_message);
2323
tvMessage.setText(message);

app/src/main/java/com/blankj/androidutilcode/core/toast/ToastActivity.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.content.Intent;
55
import android.graphics.Color;
66
import android.os.Bundle;
7+
import android.support.v4.content.ContextCompat;
78
import android.view.Gravity;
89
import android.view.View;
910

@@ -22,6 +23,8 @@
2223
*/
2324
public class ToastActivity extends BaseBackActivity {
2425

26+
View toastView;
27+
2528
public static void start(Context context) {
2629
Intent starter = new Intent(context, ToastActivity.class);
2730
context.startActivity(starter);
@@ -46,11 +49,13 @@ public void initView(Bundle savedInstanceState, View view) {
4649
findViewById(R.id.btn_show_long_toast_safe).setOnClickListener(this);
4750
findViewById(R.id.btn_show_long_toast).setOnClickListener(this);
4851
findViewById(R.id.btn_show_green_font).setOnClickListener(this);
49-
findViewById(R.id.btn_show_custom_bg).setOnClickListener(this);
52+
findViewById(R.id.btn_show_bg_color).setOnClickListener(this);
53+
findViewById(R.id.btn_show_bg_resource).setOnClickListener(this);
5054
findViewById(R.id.btn_show_span).setOnClickListener(this);
5155
findViewById(R.id.btn_show_custom_view).setOnClickListener(this);
5256
findViewById(R.id.btn_show_middle).setOnClickListener(this);
5357
findViewById(R.id.btn_cancel_toast).setOnClickListener(this);
58+
toastView = findViewById(R.id.btn_cancel_toast);
5459
}
5560

5661
@Override
@@ -85,10 +90,14 @@ public void run() {
8590
ToastUtils.showLong(R.string.toast_long);
8691
break;
8792
case R.id.btn_show_green_font:
88-
ToastUtils.setMessageColor(Color.GREEN);
93+
ToastUtils.setMsgColor(Color.GREEN);
8994
ToastUtils.showLong(R.string.toast_green_font);
9095
break;
91-
case R.id.btn_show_custom_bg:
96+
case R.id.btn_show_bg_color:
97+
ToastUtils.setBgColor(ContextCompat.getColor(this, R.color.colorAccent));
98+
ToastUtils.showLong(R.string.toast_bg_color);
99+
break;
100+
case R.id.btn_show_bg_resource:
92101
ToastUtils.setBgResource(R.drawable.shape_round_rect);
93102
ToastUtils.showLong(R.string.toast_custom_bg);
94103
break;
@@ -102,7 +111,7 @@ public void run() {
102111
);
103112
break;
104113
case R.id.btn_show_custom_view:
105-
MyToast.showMyToast(getString(R.string.toast_custom_view));
114+
CustomToast.show(getString(R.string.toast_custom_view));
106115
break;
107116
case R.id.btn_show_middle:
108117
ToastUtils.setGravity(Gravity.CENTER, 0, 0);
@@ -121,9 +130,9 @@ protected void onDestroy() {
121130
}
122131

123132
private void resetToast() {
124-
ToastUtils.setMessageColor(0xFFFFFFFF);
133+
ToastUtils.setMsgColor(0xFEFFFFFF);
134+
ToastUtils.setBgColor(0xFEFFFFFF);
125135
ToastUtils.setBgResource(-1);
126-
ToastUtils.setView(null);
127136
ToastUtils.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, getResources().getDimensionPixelSize(R.dimen.offset_64));
128137
}
129138
}

app/src/main/res/core/drawable/shape_round_rect.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33

44
<solid android:color="@color/colorAccent" />
55
<corners android:radius="@dimen/radius_16" />
6+
<padding
7+
android:bottom="@dimen/spacing_16"
8+
android:left="@dimen/spacing_16"
9+
android:right="@dimen/spacing_16"
10+
android:top="@dimen/spacing_16" />
611

712
</shape>

app/src/main/res/core/layout/activity_toast.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,18 @@
4343
android:text="@string/toast_show_green_font" />
4444

4545
<Button
46-
android:id="@+id/btn_show_custom_bg"
46+
android:id="@+id/btn_show_bg_color"
4747
style="@style/WideBtnStyle"
4848
android:layout_width="match_parent"
4949
android:layout_height="wrap_content"
50-
android:text="@string/toast_show_custom_bg" />
50+
android:text="@string/toast_show_bg_color" />
51+
52+
<Button
53+
android:id="@+id/btn_show_bg_resource"
54+
style="@style/WideBtnStyle"
55+
android:layout_width="match_parent"
56+
android:layout_height="wrap_content"
57+
android:text="@string/toast_show_bg_resource" />
5158

5259
<Button
5360
android:id="@+id/btn_show_span"

app/src/main/res/core/values/strings.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@
152152
<string name="toast_show_long_safe">Show Long Safe</string>
153153
<string name="toast_show_long">Show Long</string>
154154
<string name="toast_show_green_font">Show Green Font</string>
155-
<string name="toast_show_custom_bg">Show Custom Bg</string>
155+
<string name="toast_show_bg_color">Show Bg Color</string>
156+
<string name="toast_show_bg_resource">Show Bg Resource</string>
156157
<string name="toast_show_span">Show Span</string>
157158
<string name="toast_show_custom_view">Show Custom View</string>
158159
<string name="toast_custom_view">Custom View</string>
@@ -164,6 +165,7 @@
164165
<string name="toast_long_safe">Long Safe</string>
165166
<string name="toast_long">Long</string>
166167
<string name="toast_green_font">Green Font</string>
168+
<string name="toast_bg_color">Bg Color</string>
167169
<string name="toast_custom_bg">Custom Bg</string>
168170
<string name="toast_span">Span</string>
169171
<string name="toast_middle">Middle</string>

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ ext {
2929
minSdkVersion = 14
3030
targetSdkVersion = 25
3131

32-
versionCode = 100800500
33-
versionName = '1.8.5'
32+
versionCode = 100800600
33+
versionName = '1.8.6'
3434

3535
// App dependencies
3636
supportVersion = '25.3.1'

update_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* 17/09/02 完善ToastUtils,去除引入view带来的问题,发布版本1.8.6
12
* 17/08/30 修复ToastUtils弱引用带来的问题,修复CacheUtils异步问题,发布版本1.8.5
23
* 17/08/28 修复ToastUtils内存泄露,新增toast可根据系统字体显示不同字体,发布版本1.8.4
34
* 17/08/20 新增监听Activity生命周期,退出App,发布版本1.8.3

utilcode/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ dependencies {
6262
testCompile "org.robolectric:robolectric:$rootProject.ext.robolectricVersion"
6363
testCompile "com.google.truth:truth:0.31"
6464
}
65-
//apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle"
65+
apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle"
6666
//gradle bintrayUpload

utilcode/src/main/java/com/blankj/utilcode/util/IntentUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public final class IntentUtils {
2222

2323
private IntentUtils() {
24-
throw new UnsupportedOperationException("u can't fuck me...");
24+
throw new UnsupportedOperationException("u can't instantiate me...");
2525
}
2626

2727
/**

utilcode/src/main/java/com/blankj/utilcode/util/LogUtils.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,23 +212,17 @@ private static String[] processTagAndHead(String tag) {
212212
tag = sGlobalTag;
213213
} else {
214214
StackTraceElement targetElement = new Throwable().getStackTrace()[3];
215-
String className = targetElement.getClassName();
216-
String[] classNameInfo = className.split("\\.");
217-
if (classNameInfo.length > 0) {
218-
className = classNameInfo[classNameInfo.length - 1];
219-
}
220-
if (className.contains("$")) {
221-
className = className.split("\\$")[0];
222-
}
215+
String fileName = targetElement.getFileName();
216+
String className = fileName.substring(0, fileName.indexOf('.'));
223217
if (sTagIsSpace) {
224218
tag = isSpace(tag) ? className : tag;
225219
}
226220
if (sLogHeadSwitch) {
227221
String head = new Formatter()
228-
.format("%s, %s(%s.java:%d)",
222+
.format("%s, %s(%s:%d)",
229223
Thread.currentThread().getName(),
230224
targetElement.getMethodName(),
231-
className,
225+
fileName,
232226
targetElement.getLineNumber())
233227
.toString();
234228
return new String[]{tag, head + LINE_SEP, " [" + head + "]: "};

0 commit comments

Comments
 (0)