Skip to content

Commit 25b75a2

Browse files
committed
see 09/05 log
1 parent eb0d90c commit 25b75a2

File tree

16 files changed

+232
-269
lines changed

16 files changed

+232
-269
lines changed

README-CN.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,11 @@ Config.setGlobalTag : 设置log全局tag
323323
Config.setLogHeadSwitch : 设置log头部信息开关
324324
Config.setLog2FileSwitch: 设置log文件开关
325325
Config.setDir : 设置log文件存储目录
326+
Config.setFilePrefix : 设置log文件前缀
326327
Config.setBorderSwitch : 设置log边框开关
327328
Config.setConsoleFilter : 设置log控制台过滤器
328329
Config.setFileFilter : 设置log文件过滤器
330+
Config.setStackDeep : 设置log栈深度
329331
v : Verbose日志
330332
d : Debug日志
331333
i : Info日志
@@ -574,19 +576,15 @@ getZodiac : 获取星座
574576

575577
* ### 吐司相关→[ToastUtils.java][toast.java][Demo][toast.demo]
576578
```
577-
setGravity : 设置吐司位置
578-
setBgColor : 设置背景颜色
579-
setBgResource : 设置背景资源
580-
setMessageColor : 设置消息颜色
581-
showShortSafe : 安全地显示短时吐司
582-
showLongSafe : 安全地显示长时吐司
583-
showShort : 显示短时吐司
584-
showLong : 显示长时吐司
585-
showCustomShortSafe: 安全地显示短时自定义吐司
586-
showCustomLongSafe : 安全地显示长时自定义吐司
587-
showCustomShort : 显示短时自定义吐司
588-
showCustomLong : 显示长时自定义吐司
589-
cancel : 取消吐司显示
579+
setGravity : 设置吐司位置
580+
setBgColor : 设置背景颜色
581+
setBgResource : 设置背景资源
582+
setMessageColor: 设置消息颜色
583+
showShort : 显示短时吐司
584+
showLong : 显示长时吐司
585+
showCustomShort: 显示短时自定义吐司
586+
showCustomLong : 显示长时自定义吐司
587+
cancel : 取消吐司显示
590588
```
591589

592590
* ### 压缩相关→[ZipUtils.java][zip.java][Test][zip.test]
@@ -616,7 +614,7 @@ getEntries : 获取压缩文件中的文件对象
616614

617615
Gradle:
618616
``` groovy
619-
compile 'com.blankj:utilcode:1.8.6'
617+
compile 'com.blankj:utilcode:1.9.0'
620618
```
621619

622620

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

640638
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
641639

642-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.8.6-brightgreen.svg
640+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.0-brightgreen.svg
643641
[auc]: https://github.com/Blankj/AndroidUtilCode
644642

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

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,11 @@ Config.setGlobalTag
323323
Config.setLogHeadSwitch
324324
Config.setLog2FileSwitch
325325
Config.setDir
326+
Config.setFilePrefix
326327
Config.setBorderSwitch
327328
Config.setConsoleFilter
328329
Config.setFileFilter
330+
Config.setStackDeep
329331
v
330332
d
331333
i
@@ -578,12 +580,8 @@ setGravity
578580
setBgColor
579581
setBgResource
580582
setMessageColor
581-
showShortSafe
582-
showLongSafe
583583
showShort
584584
showLong
585-
showCustomShortSafe
586-
showCustomLongSafe
587585
showCustomShort
588586
showCustomLong
589587
cancel
@@ -616,7 +614,7 @@ getEntries
616614

617615
Gradle:
618616
``` groovy
619-
compile 'com.blankj:utilcode:1.8.6'
617+
compile 'com.blankj:utilcode:1.9.0'
620618
```
621619

622620

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

640638
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
641639

642-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.8.6-brightgreen.svg
640+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.0-brightgreen.svg
643641
[auc]: https://github.com/Blankj/AndroidUtilCode
644642

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

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565

6666

6767
<!--core-->
68-
<activity android:name=".core.main.CoreUtilActivity" />
68+
<activity
69+
android:name=".core.main.CoreUtilActivity" />
6970
<activity android:name=".core.activity.ActivityActivity" />
7071
<activity android:name=".core.app.AppActivity" />
7172
<activity android:name=".core.bar.BarActivity" />

app/src/main/java/com/blankj/androidutilcode/UtilsApp.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public void initLog() {
6262
.setFilePrefix("")// 当文件前缀为空时,默认为"util",即写入文件为"util-MM-dd.txt"
6363
.setBorderSwitch(true)// 输出日志是否带边框开关,默认开
6464
.setConsoleFilter(LogUtils.V)// log的控制台过滤器,和logcat过滤器同理,默认Verbose
65-
.setFileFilter(LogUtils.V);// log文件过滤器,和logcat过滤器同理,默认Verbose
65+
.setFileFilter(LogUtils.V)// log文件过滤器,和logcat过滤器同理,默认Verbose
66+
.setStackDeep(1);// log栈深度,默认为1
6667
LogUtils.d(config.toString());
6768
}
6869

app/src/main/java/com/blankj/androidutilcode/core/app/AppActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ public void onWidgetClick(View view) {
8282
@Override
8383
public void run() {
8484
if (AppUtils.isInstallApp(Config.TEST_PKG)) {
85-
ToastUtils.showShortSafe(R.string.app_install_tips);
85+
ToastUtils.showShort(R.string.app_install_tips);
8686
} else {
8787
if (AppUtils.installAppSilent(Config.getTestApkPath())) {
88-
ToastUtils.showShortSafe(R.string.install_successfully);
88+
ToastUtils.showShort(R.string.install_successfully);
8989
} else {
90-
ToastUtils.showShortSafe(R.string.install_unsuccessfully);
90+
ToastUtils.showShort(R.string.install_unsuccessfully);
9191
}
9292
}
9393
}

app/src/main/java/com/blankj/androidutilcode/core/log/LogActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public int bindLayout() {
9292
public void initView(Bundle savedInstanceState, View view) {
9393
getToolBar().setTitle(getString(R.string.demo_log));
9494

95+
tvAboutLog = (TextView) findViewById(R.id.tv_about_log);
9596
findViewById(R.id.btn_toggle_log).setOnClickListener(this);
9697
findViewById(R.id.btn_toggle_console).setOnClickListener(this);
9798
findViewById(R.id.btn_toggle_tag).setOnClickListener(this);
@@ -110,7 +111,6 @@ public void initView(Bundle savedInstanceState, View view) {
110111
findViewById(R.id.btn_log_file).setOnClickListener(this);
111112
findViewById(R.id.btn_log_json).setOnClickListener(this);
112113
findViewById(R.id.btn_log_xml).setOnClickListener(this);
113-
tvAboutLog = (TextView) findViewById(R.id.tv_about_log);
114114
updateAbout(0);
115115
}
116116

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,88 @@
11
package com.blankj.androidutilcode.core.toast;
22

3+
import android.os.Handler;
4+
import android.os.Looper;
35
import android.support.annotation.NonNull;
4-
import android.view.View;
6+
import android.support.annotation.StringRes;
57
import android.widget.TextView;
8+
import android.widget.Toast;
69

710
import com.blankj.androidutilcode.R;
11+
import com.blankj.androidutilcode.UtilsApp;
812
import com.blankj.utilcode.util.ToastUtils;
913

1014
/**
1115
* <pre>
1216
* author: Blankj
1317
* blog : http://blankj.com
1418
* time : 2017/08/31
15-
* desc :
19+
* desc : 自定义Toast
1620
* </pre>
1721
*/
1822
public class CustomToast {
1923

20-
public static void show(@NonNull final String message){
21-
View toastView = ToastUtils.showCustomLongSafe(R.layout.toast_custom);
22-
TextView tvMessage = (TextView) toastView.findViewById(R.id.tv_toast_message);
23-
tvMessage.setText(message);
24+
private static final Handler HANDLER = new Handler(Looper.getMainLooper());
25+
26+
public static void showShort(@NonNull final CharSequence text) {
27+
show(text, Toast.LENGTH_SHORT);
28+
}
29+
30+
public static void showShort(@StringRes final int resId) {
31+
show(resId, Toast.LENGTH_SHORT);
32+
}
33+
34+
public static void showShort(@StringRes final int resId, final Object... args) {
35+
show(resId, Toast.LENGTH_SHORT, args);
36+
}
37+
38+
public static void showShort(final String format, final Object... args) {
39+
show(format, Toast.LENGTH_SHORT, args);
40+
}
41+
42+
public static void showLong(@NonNull final CharSequence text) {
43+
show(text, Toast.LENGTH_LONG);
44+
}
45+
46+
public static void showLong(@StringRes final int resId) {
47+
show(resId, Toast.LENGTH_LONG);
48+
}
49+
50+
public static void showLong(@StringRes final int resId, final Object... args) {
51+
show(resId, Toast.LENGTH_LONG, args);
52+
}
53+
54+
public static void showLong(final String format, final Object... args) {
55+
show(format, Toast.LENGTH_LONG, args);
56+
}
57+
58+
private static void show(@StringRes final int resId, final int duration) {
59+
show(UtilsApp.getInstance().getResources().getString(resId), duration);
60+
}
61+
62+
private static void show(@StringRes final int resId, final int duration, final Object... args) {
63+
show(String.format(UtilsApp.getInstance().getResources().getString(resId), args), duration);
64+
}
65+
66+
private static void show(final String format, final int duration, final Object... args) {
67+
show(String.format(format, args), duration);
2468
}
2569

70+
private static void show(final CharSequence text, final int duration) {
71+
HANDLER.post(new Runnable() {
72+
@Override
73+
public void run() {
74+
TextView toastView;
75+
if (duration == Toast.LENGTH_SHORT) {
76+
toastView = (TextView) ToastUtils.showCustomShort(R.layout.toast_custom);
77+
} else {
78+
toastView = (TextView) ToastUtils.showCustomLong(R.layout.toast_custom);
79+
}
80+
toastView.setText(text);
81+
}
82+
});
83+
}
84+
85+
public static void cancel() {
86+
ToastUtils.cancel();
87+
}
2688
}

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import com.blankj.androidutilcode.R;
1212
import com.blankj.androidutilcode.base.BaseBackActivity;
13+
import com.blankj.utilcode.util.ActivityUtils;
1314
import com.blankj.utilcode.util.SpanUtils;
1415
import com.blankj.utilcode.util.ToastUtils;
1516

@@ -28,6 +29,7 @@ public class ToastActivity extends BaseBackActivity {
2829
public static void start(Context context) {
2930
Intent starter = new Intent(context, ToastActivity.class);
3031
context.startActivity(starter);
32+
ActivityUtils.startActivity(ToastActivity.class);
3133
}
3234

3335
@Override
@@ -44,9 +46,7 @@ public int bindLayout() {
4446
public void initView(Bundle savedInstanceState, View view) {
4547
getToolBar().setTitle(getString(R.string.demo_toast));
4648

47-
findViewById(R.id.btn_show_short_toast_safe).setOnClickListener(this);
4849
findViewById(R.id.btn_show_short_toast).setOnClickListener(this);
49-
findViewById(R.id.btn_show_long_toast_safe).setOnClickListener(this);
5050
findViewById(R.id.btn_show_long_toast).setOnClickListener(this);
5151
findViewById(R.id.btn_show_green_font).setOnClickListener(this);
5252
findViewById(R.id.btn_show_bg_color).setOnClickListener(this);
@@ -67,28 +67,22 @@ public void doBusiness() {
6767
public void onWidgetClick(View view) {
6868
resetToast();
6969
switch (view.getId()) {
70-
case R.id.btn_show_short_toast_safe:
70+
case R.id.btn_show_short_toast:
7171
new Thread(new Runnable() {
7272
@Override
7373
public void run() {
74-
ToastUtils.showShortSafe(R.string.toast_short_safe);
74+
ToastUtils.showShort(R.string.toast_short);
7575
}
7676
}).start();
7777
break;
78-
case R.id.btn_show_short_toast:
79-
ToastUtils.showShort(R.string.toast_short);
80-
break;
81-
case R.id.btn_show_long_toast_safe:
78+
case R.id.btn_show_long_toast:
8279
new Thread(new Runnable() {
8380
@Override
8481
public void run() {
85-
ToastUtils.showLongSafe(R.string.toast_long_safe);
82+
ToastUtils.showLong(R.string.toast_long);
8683
}
8784
}).start();
8885
break;
89-
case R.id.btn_show_long_toast:
90-
ToastUtils.showLong(R.string.toast_long);
91-
break;
9286
case R.id.btn_show_green_font:
9387
ToastUtils.setMsgColor(Color.GREEN);
9488
ToastUtils.showLong(R.string.toast_green_font);
@@ -111,7 +105,12 @@ public void run() {
111105
);
112106
break;
113107
case R.id.btn_show_custom_view:
114-
CustomToast.show(getString(R.string.toast_custom_view));
108+
new Thread(new Runnable() {
109+
@Override
110+
public void run() {
111+
CustomToast.showLong(R.string.toast_custom_view);
112+
}
113+
}).start();
115114
break;
116115
case R.id.btn_show_middle:
117116
ToastUtils.setGravity(Gravity.CENTER, 0, 0);

app/src/main/java/com/blankj/androidutilcode/sub/location/LocationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void onCreate() {
7575
public void run() {
7676
Looper.prepare();
7777
isSuccess = LocationUtils.register(0, 0, mOnLocationChangeListener);
78-
if (isSuccess) ToastUtils.showShortSafe("init success");
78+
if (isSuccess) ToastUtils.showShort("init success");
7979
Looper.loop();
8080
}
8181
}).start();

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,13 @@
77
android:orientation="vertical"
88
android:padding="@dimen/spacing_16">
99

10-
<Button
11-
android:id="@+id/btn_show_short_toast_safe"
12-
style="@style/WideBtnStyle"
13-
android:layout_width="match_parent"
14-
android:layout_height="wrap_content"
15-
android:text="@string/toast_show_short_safe" />
16-
1710
<Button
1811
android:id="@+id/btn_show_short_toast"
1912
style="@style/WideBtnStyle"
2013
android:layout_width="match_parent"
2114
android:layout_height="wrap_content"
2215
android:text="@string/toast_show_short" />
2316

24-
<Button
25-
android:id="@+id/btn_show_long_toast_safe"
26-
style="@style/WideBtnStyle"
27-
android:layout_width="match_parent"
28-
android:layout_height="wrap_content"
29-
android:text="@string/toast_show_long_safe" />
30-
3117
<Button
3218
android:id="@+id/btn_show_long_toast"
3319
style="@style/WideBtnStyle"

0 commit comments

Comments
 (0)