GeezerVison is showing github.com — see 09/05 log · bbbBBBSG/AndroidUtilCode@25b75a2
File treeExpand file treeCollapse file tree Open diff view settings java/com/blankj/androidutilcode
main/java/com/blankj/utilcode/util test/java/com/blankj/utilcode/util
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: README-CN.md +13-15Lines changed: 13 additions & 15 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -323,9 +323,11 @@ Config.setGlobalTag : 设置log全局tag | 323 | 323 | Config.setLogHeadSwitch : 设置log头部信息开关 | 324 | 324 | Config.setLog2FileSwitch: 设置log文件开关 | 325 | 325 | Config.setDir : 设置log文件存储目录 | | 326 | +Config.setFilePrefix : 设置log文件前缀 | 326 | 327 | Config.setBorderSwitch : 设置log边框开关 | 327 | 328 | Config.setConsoleFilter : 设置log控制台过滤器 | 328 | 329 | Config.setFileFilter : 设置log文件过滤器 | | 330 | +Config.setStackDeep : 设置log栈深度 | 329 | 331 | v : Verbose日志 | 330 | 332 | d : Debug日志 | 331 | 333 | i : Info日志 | @@ -574,19 +576,15 @@ getZodiac : 获取星座 | 574 | 576 |
| 575 | 577 | * ### 吐司相关→[ToastUtils.java][toast.java]→[Demo][toast.demo] | 576 | 578 | ``` | 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 : 取消吐司显示 | 590 | 588 | ``` | 591 | 589 |
| 592 | 590 | * ### 压缩相关→[ZipUtils.java][zip.java]→[Test][zip.test] | @@ -616,7 +614,7 @@ getEntries : 获取压缩文件中的文件对象 | 616 | 614 |
| 617 | 615 | Gradle: | 618 | 616 | ``` groovy | 619 | | -compile 'com.blankj:utilcode:1.8.6' | | 617 | +compile 'com.blankj:utilcode:1.9.0' | 620 | 618 | ``` | 621 | 619 |
| 622 | 620 |
| @@ -639,7 +637,7 @@ Utils.init(context); | 639 | 637 |
| 640 | 638 | [logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png | 641 | 639 |
| 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 | 643 | 641 | [auc]: https://github.com/Blankj/AndroidUtilCode | 644 | 642 |
| 645 | 643 | [apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg | |
Collapse file Copy file name to clipboardExpand all lines: README.md +4-6Lines changed: 4 additions & 6 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -323,9 +323,11 @@ Config.setGlobalTag | 323 | 323 | Config.setLogHeadSwitch | 324 | 324 | Config.setLog2FileSwitch | 325 | 325 | Config.setDir | | 326 | +Config.setFilePrefix | 326 | 327 | Config.setBorderSwitch | 327 | 328 | Config.setConsoleFilter | 328 | 329 | Config.setFileFilter | | 330 | +Config.setStackDeep | 329 | 331 | v | 330 | 332 | d | 331 | 333 | i | @@ -578,12 +580,8 @@ setGravity | 578 | 580 | setBgColor | 579 | 581 | setBgResource | 580 | 582 | setMessageColor | 581 | | -showShortSafe | 582 | | -showLongSafe | 583 | 583 | showShort | 584 | 584 | showLong | 585 | | -showCustomShortSafe | 586 | | -showCustomLongSafe | 587 | 585 | showCustomShort | 588 | 586 | showCustomLong | 589 | 587 | cancel | @@ -616,7 +614,7 @@ getEntries | 616 | 614 |
| 617 | 615 | Gradle: | 618 | 616 | ``` groovy | 619 | | -compile 'com.blankj:utilcode:1.8.6' | | 617 | +compile 'com.blankj:utilcode:1.9.0' | 620 | 618 | ``` | 621 | 619 |
| 622 | 620 |
| @@ -639,7 +637,7 @@ Utils.init(context); | 639 | 637 |
| 640 | 638 | [logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png | 641 | 639 |
| 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 | 643 | 641 | [auc]: https://github.com/Blankj/AndroidUtilCode | 644 | 642 |
| 645 | 643 | [apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/AndroidManifest.xml +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 65 | 65 |
| 66 | 66 |
| 67 | 67 | <!--core--> | 68 | | - <activity android:name=".core.main.CoreUtilActivity" /> | | 68 | + <activity | | 69 | + android:name=".core.main.CoreUtilActivity" /> | 69 | 70 | <activity android:name=".core.activity.ActivityActivity" /> | 70 | 71 | <activity android:name=".core.app.AppActivity" /> | 71 | 72 | <activity android:name=".core.bar.BarActivity" /> | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/blankj/androidutilcode/UtilsApp.java +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -62,7 +62,8 @@ public void initLog() { | 62 | 62 | .setFilePrefix("")// 当文件前缀为空时,默认为"util",即写入文件为"util-MM-dd.txt" | 63 | 63 | .setBorderSwitch(true)// 输出日志是否带边框开关,默认开 | 64 | 64 | .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 | 66 | 67 | LogUtils.d(config.toString()); | 67 | 68 | } | 68 | 69 |
| |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/blankj/androidutilcode/core/app/AppActivity.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -82,12 +82,12 @@ public void onWidgetClick(View view) { | 82 | 82 | @Override | 83 | 83 | public void run() { | 84 | 84 | if (AppUtils.isInstallApp(Config.TEST_PKG)) { | 85 | | - ToastUtils.showShortSafe(R.string.app_install_tips); | | 85 | + ToastUtils.showShort(R.string.app_install_tips); | 86 | 86 | } else { | 87 | 87 | if (AppUtils.installAppSilent(Config.getTestApkPath())) { | 88 | | - ToastUtils.showShortSafe(R.string.install_successfully); | | 88 | + ToastUtils.showShort(R.string.install_successfully); | 89 | 89 | } else { | 90 | | - ToastUtils.showShortSafe(R.string.install_unsuccessfully); | | 90 | + ToastUtils.showShort(R.string.install_unsuccessfully); | 91 | 91 | } | 92 | 92 | } | 93 | 93 | } | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/blankj/androidutilcode/core/log/LogActivity.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,6 +92,7 @@ public int bindLayout() { | 92 | 92 | public void initView(Bundle savedInstanceState, View view) { | 93 | 93 | getToolBar().setTitle(getString(R.string.demo_log)); | 94 | 94 |
| | 95 | + tvAboutLog = (TextView) findViewById(R.id.tv_about_log); | 95 | 96 | findViewById(R.id.btn_toggle_log).setOnClickListener(this); | 96 | 97 | findViewById(R.id.btn_toggle_console).setOnClickListener(this); | 97 | 98 | findViewById(R.id.btn_toggle_tag).setOnClickListener(this); | @@ -110,7 +111,6 @@ public void initView(Bundle savedInstanceState, View view) { | 110 | 111 | findViewById(R.id.btn_log_file).setOnClickListener(this); | 111 | 112 | findViewById(R.id.btn_log_json).setOnClickListener(this); | 112 | 113 | findViewById(R.id.btn_log_xml).setOnClickListener(this); | 113 | | - tvAboutLog = (TextView) findViewById(R.id.tv_about_log); | 114 | 114 | updateAbout(0); | 115 | 115 | } | 116 | 116 |
| |
Collapse file Copy file name to clipboard +68-6Lines changed: 68 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | package com.blankj.androidutilcode.core.toast; | 2 | 2 |
| | 3 | +import android.os.Handler; | | 4 | +import android.os.Looper; | 3 | 5 | import android.support.annotation.NonNull; | 4 | | -import android.view.View; | | 6 | +import android.support.annotation.StringRes; | 5 | 7 | import android.widget.TextView; | | 8 | +import android.widget.Toast; | 6 | 9 |
| 7 | 10 | import com.blankj.androidutilcode.R; | | 11 | +import com.blankj.androidutilcode.UtilsApp; | 8 | 12 | import com.blankj.utilcode.util.ToastUtils; | 9 | 13 |
| 10 | 14 | /** | 11 | 15 | * <pre> | 12 | 16 | * author: Blankj | 13 | 17 | * blog : http://blankj.com | 14 | 18 | * time : 2017/08/31 | 15 | | - * desc : | | 19 | + * desc : 自定义Toast | 16 | 20 | * </pre> | 17 | 21 | */ | 18 | 22 | public class CustomToast { | 19 | 23 |
| 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); | 24 | 68 | } | 25 | 69 |
| | 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 | + } | 26 | 88 | } |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/blankj/androidutilcode/core/toast/ToastActivity.java +12-13Lines changed: 12 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 |
| 11 | 11 | import com.blankj.androidutilcode.R; | 12 | 12 | import com.blankj.androidutilcode.base.BaseBackActivity; | | 13 | +import com.blankj.utilcode.util.ActivityUtils; | 13 | 14 | import com.blankj.utilcode.util.SpanUtils; | 14 | 15 | import com.blankj.utilcode.util.ToastUtils; | 15 | 16 |
| @@ -28,6 +29,7 @@ public class ToastActivity extends BaseBackActivity { | 28 | 29 | public static void start(Context context) { | 29 | 30 | Intent starter = new Intent(context, ToastActivity.class); | 30 | 31 | context.startActivity(starter); | | 32 | + ActivityUtils.startActivity(ToastActivity.class); | 31 | 33 | } | 32 | 34 |
| 33 | 35 | @Override | @@ -44,9 +46,7 @@ public int bindLayout() { | 44 | 46 | public void initView(Bundle savedInstanceState, View view) { | 45 | 47 | getToolBar().setTitle(getString(R.string.demo_toast)); | 46 | 48 |
| 47 | | - findViewById(R.id.btn_show_short_toast_safe).setOnClickListener(this); | 48 | 49 | findViewById(R.id.btn_show_short_toast).setOnClickListener(this); | 49 | | - findViewById(R.id.btn_show_long_toast_safe).setOnClickListener(this); | 50 | 50 | findViewById(R.id.btn_show_long_toast).setOnClickListener(this); | 51 | 51 | findViewById(R.id.btn_show_green_font).setOnClickListener(this); | 52 | 52 | findViewById(R.id.btn_show_bg_color).setOnClickListener(this); | @@ -67,28 +67,22 @@ public void doBusiness() { | 67 | 67 | public void onWidgetClick(View view) { | 68 | 68 | resetToast(); | 69 | 69 | switch (view.getId()) { | 70 | | - case R.id.btn_show_short_toast_safe: | | 70 | + case R.id.btn_show_short_toast: | 71 | 71 | new Thread(new Runnable() { | 72 | 72 | @Override | 73 | 73 | public void run() { | 74 | | - ToastUtils.showShortSafe(R.string.toast_short_safe); | | 74 | + ToastUtils.showShort(R.string.toast_short); | 75 | 75 | } | 76 | 76 | }).start(); | 77 | 77 | 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: | 82 | 79 | new Thread(new Runnable() { | 83 | 80 | @Override | 84 | 81 | public void run() { | 85 | | - ToastUtils.showLongSafe(R.string.toast_long_safe); | | 82 | + ToastUtils.showLong(R.string.toast_long); | 86 | 83 | } | 87 | 84 | }).start(); | 88 | 85 | break; | 89 | | - case R.id.btn_show_long_toast: | 90 | | - ToastUtils.showLong(R.string.toast_long); | 91 | | - break; | 92 | 86 | case R.id.btn_show_green_font: | 93 | 87 | ToastUtils.setMsgColor(Color.GREEN); | 94 | 88 | ToastUtils.showLong(R.string.toast_green_font); | @@ -111,7 +105,12 @@ public void run() { | 111 | 105 | ); | 112 | 106 | break; | 113 | 107 | 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(); | 115 | 114 | break; | 116 | 115 | case R.id.btn_show_middle: | 117 | 116 | ToastUtils.setGravity(Gravity.CENTER, 0, 0); | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/java/com/blankj/androidutilcode/sub/location/LocationService.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -75,7 +75,7 @@ public void onCreate() { | 75 | 75 | public void run() { | 76 | 76 | Looper.prepare(); | 77 | 77 | isSuccess = LocationUtils.register(0, 0, mOnLocationChangeListener); | 78 | | - if (isSuccess) ToastUtils.showShortSafe("init success"); | | 78 | + if (isSuccess) ToastUtils.showShort("init success"); | 79 | 79 | Looper.loop(); | 80 | 80 | } | 81 | 81 | }).start(); | |
Collapse file Copy file name to clipboardExpand all lines: app/src/main/res/core/layout/activity_toast.xml -14Lines changed: 0 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 | android:orientation="vertical" | 8 | 8 | android:padding="@dimen/spacing_16"> | 9 | 9 |
| 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 | | - | 17 | 10 | <Button | 18 | 11 | android:id="@+id/btn_show_short_toast" | 19 | 12 | style="@style/WideBtnStyle" | 20 | 13 | android:layout_width="match_parent" | 21 | 14 | android:layout_height="wrap_content" | 22 | 15 | android:text="@string/toast_show_short" /> | 23 | 16 |
| 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 | | - | 31 | 17 | <Button | 32 | 18 | android:id="@+id/btn_show_long_toast" | 33 | 19 | style="@style/WideBtnStyle" | |
|