Skip to content

Commit 07925ad

Browse files
committed
see 08/09 log
1 parent 205943d commit 07925ad

File tree

13 files changed

+45
-34
lines changed

13 files changed

+45
-34
lines changed

README-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.5-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.6-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

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

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.5-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.6-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

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

apk/output.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1018005,"versionName":"1.18.5","enabled":true,"outputFile":"util_1_18_5.apk","fullName":"release","baseName":"release"},"path":"util_1_18_5.apk","properties":{}}]
1+
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1018006,"versionName":"1.18.6","enabled":true,"outputFile":"util_1_18_6.apk","fullName":"release","baseName":"release"},"path":"util_1_18_6.apk","properties":{}}]
5.88 MB
Binary file not shown.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void initLog() {
6363
.setLogHeadSwitch(true)// 设置 log 头信息开关,默认为开
6464
.setLog2FileSwitch(false)// 打印 log 时是否存到文件的开关,默认关
6565
.setDir("")// 当自定义路径为空时,写入应用的/cache/log/目录中
66-
.setFilePrefix("")// 当文件前缀为空时,默认为"util",即写入文件为"util-MM-dd.txt"
66+
.setFilePrefix("")// 当文件前缀为空时,默认为"util",即写入文件为"util-yyyy-MM-dd.txt"
6767
.setBorderSwitch(true)// 输出日志是否带边框开关,默认开
6868
.setSingleTagSwitch(true)// 一条日志仅输出一条,默认开,为美化 AS 3.1 的 Logcat
6969
.setConsoleFilter(LogUtils.V)// log 的控制台过滤器,和 logcat 过滤器同理,默认 Verbose

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

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.support.v4.content.ContextCompat;
99
import android.view.Gravity;
1010
import android.view.View;
11+
import android.widget.Toast;
1112

1213
import com.blankj.androidutilcode.R;
1314
import com.blankj.androidutilcode.base.BaseBackActivity;

config.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ext {
66
compileSdkVersion: 27,
77
minSdkVersion : 14,
88
targetSdkVersion : 27,
9-
versionCode : 1_018_005,
10-
versionName : '1.18.5'// E.g 1.9.72 => 1,009,072
9+
versionCode : 1_018_006,
10+
versionName : '1.18.6'// E.g 1.9.72 => 1,009,072
1111
]
1212

1313
versionConfig = [
@@ -167,7 +167,7 @@ def configAppDependencies(Project pro) {
167167
// LeakCanary
168168
debugImplementation depConfig.leakcanary.android
169169
releaseImplementation depConfig.leakcanary.android_no_op
170-
// implementation 'com.blankj:utilcode:1.18.5'
170+
// implementation 'com.blankj:utilcode:1.18.6'
171171
}
172172
}
173173

update_log.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* 18/08/09 新增 IntentUtils#isIntentAvailable,ToastUtils 传入空显示 null,发布 1.18.6
12
* 18/08/08 修复 ScreenUtils#adaptxx 在第三方 SDK 会出现的问题,发布 1.18.5
23
* 18/08/07 修复 ScreenUtils#adaptxx 在 API 26 以下无效的 bug,发布 1.18.4
34
* 18/08/06 修复 ScreenUtils#screenShot 中 decorView.getDrawingCache() 为空的问题,发布 1.18.3

utilcode/README-CN.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.18.5'
5+
implementation 'com.blankj:utilcode:1.18.6'
66
```
77

88

@@ -347,6 +347,7 @@ compressBySampleSize : 按采样大小压缩
347347

348348
* ### 意图相关 -> [IntentUtils.java][intent.java]
349349
```
350+
isIntentAvailable : 判断意图是否可用
350351
getInstallAppIntent : 获取安装 App(支持 6.0)的意图
351352
getUninstallAppIntent : 获取卸载 App 的意图
352353
getLaunchAppIntent : 获取打开 App 的意图

utilcode/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.18.5'
5+
implementation 'com.blankj:utilcode:1.18.6'
66
```
77

88

@@ -347,6 +347,7 @@ compressBySampleSize
347347

348348
* ### About Intent -> [IntentUtils.java][intent.java]
349349
```
350+
isIntentAvailable
350351
getInstallAppIntent
351352
getUninstallAppIntent
352353
getLaunchAppIntent

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

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ private IntentUtils() {
3030
throw new UnsupportedOperationException("u can't instantiate me...");
3131
}
3232

33+
/**
34+
* Return whether the intent is available.
35+
*
36+
* @param intent The intent.
37+
* @return {@code true}: yes<br>{@code false}: no
38+
*/
39+
public static boolean isIntentAvailable(final Intent intent) {
40+
return Utils.getApp().getPackageManager().queryIntentActivities(intent, 0).size() > 0;
41+
}
42+
3343
/**
3444
* Return the intent of install app.
3545
* <p>Target APIs greater than 25 must hold

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

+2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public static boolean isTablet() {
302302
/**
303303
* Adapt the screen for vertical slide.
304304
*
305+
* @param activity The activity.
305306
* @param designWidthInPx The size of design diagram's width, in pixel.
306307
*/
307308
public static void adaptScreen4VerticalSlide(final Activity activity,
@@ -312,6 +313,7 @@ public static void adaptScreen4VerticalSlide(final Activity activity,
312313
/**
313314
* Adapt the screen for horizontal slide.
314315
*
316+
* @param activity The activity.
315317
* @param designHeightInPx The size of design diagram's height, in pixel.
316318
*/
317319
public static void adaptScreen4HorizontalSlide(final Activity activity,

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

+20-25
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public final class ToastUtils {
3939

4040
private static final int COLOR_DEFAULT = 0xFEFFFFFF;
4141
private static final Handler HANDLER = new Handler(Looper.getMainLooper());
42+
private static final String NULL = "null";
4243

4344
private static Toast sToast;
4445
private static int sGravity = -1;
@@ -107,8 +108,8 @@ public static void setMsgTextSize(final int textSize) {
107108
*
108109
* @param text The text.
109110
*/
110-
public static void showShort(@NonNull final CharSequence text) {
111-
show(text, Toast.LENGTH_SHORT);
111+
public static void showShort(final CharSequence text) {
112+
show(text == null ? NULL : text, Toast.LENGTH_SHORT);
112113
}
113114

114115
/**
@@ -127,11 +128,7 @@ public static void showShort(@StringRes final int resId) {
127128
* @param args The args.
128129
*/
129130
public static void showShort(@StringRes final int resId, final Object... args) {
130-
if (args != null && args.length == 0) {
131-
show(resId, Toast.LENGTH_SHORT);
132-
} else {
133-
show(resId, Toast.LENGTH_SHORT, args);
134-
}
131+
show(resId, Toast.LENGTH_SHORT, args);
135132
}
136133

137134
/**
@@ -141,20 +138,16 @@ public static void showShort(@StringRes final int resId, final Object... args) {
141138
* @param args The args.
142139
*/
143140
public static void showShort(final String format, final Object... args) {
144-
if (args != null && args.length == 0) {
145-
show(format, Toast.LENGTH_SHORT);
146-
} else {
147-
show(format, Toast.LENGTH_SHORT, args);
148-
}
141+
show(format, Toast.LENGTH_SHORT, args);
149142
}
150143

151144
/**
152145
* Show the sToast for a long period of time.
153146
*
154147
* @param text The text.
155148
*/
156-
public static void showLong(@NonNull final CharSequence text) {
157-
show(text, Toast.LENGTH_LONG);
149+
public static void showLong(final CharSequence text) {
150+
show(text == null ? NULL : text, Toast.LENGTH_LONG);
158151
}
159152

160153
/**
@@ -173,11 +166,7 @@ public static void showLong(@StringRes final int resId) {
173166
* @param args The args.
174167
*/
175168
public static void showLong(@StringRes final int resId, final Object... args) {
176-
if (args != null && args.length == 0) {
177-
show(resId, Toast.LENGTH_SHORT);
178-
} else {
179-
show(resId, Toast.LENGTH_LONG, args);
180-
}
169+
show(resId, Toast.LENGTH_LONG, args);
181170
}
182171

183172
/**
@@ -187,11 +176,7 @@ public static void showLong(@StringRes final int resId, final Object... args) {
187176
* @param args The args.
188177
*/
189178
public static void showLong(final String format, final Object... args) {
190-
if (args != null && args.length == 0) {
191-
show(format, Toast.LENGTH_SHORT);
192-
} else {
193-
show(format, Toast.LENGTH_LONG, args);
194-
}
179+
show(format, Toast.LENGTH_LONG, args);
195180
}
196181

197182
/**
@@ -234,7 +219,16 @@ private static void show(@StringRes final int resId, final int duration, final O
234219
}
235220

236221
private static void show(final String format, final int duration, final Object... args) {
237-
show(String.format(format, args), duration);
222+
String text;
223+
if (format == null) {
224+
text = NULL;
225+
} else {
226+
text = String.format(format, args);
227+
if (text == null) {
228+
text = NULL;
229+
}
230+
}
231+
show(text, duration);
238232
}
239233

240234
private static void show(final CharSequence text, final int duration) {
@@ -280,6 +274,7 @@ public void run() {
280274
private static void showToast() {
281275
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1) {
282276
try {
277+
//noinspection JavaReflectionMemberAccess
283278
Field field = View.class.getDeclaredField("mContext");
284279
field.setAccessible(true);
285280
field.set(sToast.getView(), new ApplicationContextWrapperForApi25());

0 commit comments

Comments
 (0)