Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xiaoxuan_i809
AndroidUtilCode
提交
368926cc
A
AndroidUtilCode
项目概览
xiaoxuan_i809
/
AndroidUtilCode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AndroidUtilCode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
368926cc
编写于
1月 07, 2019
作者:
B
Blankj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
see 01/07 log
上级
1e20b865
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
229 addition
and
104 deletion
+229
-104
CHANGELOG.md
CHANGELOG.md
+2
-0
README-CN.md
README-CN.md
+1
-1
README.md
README.md
+1
-1
config.gradle
config.gradle
+2
-2
lib/base/build.gradle
lib/base/build.gradle
+1
-1
utilcode/README-CN.md
utilcode/README-CN.md
+1
-1
utilcode/README-STATIC-BUS.md
utilcode/README-STATIC-BUS.md
+1
-1
utilcode/README.md
utilcode/README.md
+1
-1
utilcode/lib/src/main/java/com/blankj/utilcode/util/JsonUtils.java
...lib/src/main/java/com/blankj/utilcode/util/JsonUtils.java
+207
-79
utilcode/lib/src/test/java/com/blankj/utilcode/util/CacheMemoryStaticUtilsTest.java
.../com/blankj/utilcode/util/CacheMemoryStaticUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/CacheMemoryUtilsTest.java
...t/java/com/blankj/utilcode/util/CacheMemoryUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/ConvertUtilsTest.java
.../test/java/com/blankj/utilcode/util/ConvertUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/FileIOUtilsTest.java
...c/test/java/com/blankj/utilcode/util/FileIOUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/FileUtilsTest.java
...src/test/java/com/blankj/utilcode/util/FileUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/GsonUtilsTest.java
...src/test/java/com/blankj/utilcode/util/GsonUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/ObjectUtilsTest.java
...c/test/java/com/blankj/utilcode/util/ObjectUtilsTest.java
+1
-6
utilcode/lib/src/test/java/com/blankj/utilcode/util/RegexUtilsTest.java
...rc/test/java/com/blankj/utilcode/util/RegexUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/StringUtilsTest.java
...c/test/java/com/blankj/utilcode/util/StringUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/ThreadUtilsTest.java
...c/test/java/com/blankj/utilcode/util/ThreadUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/TimeUtilsTest.java
...src/test/java/com/blankj/utilcode/util/TimeUtilsTest.java
+1
-1
utilcode/lib/src/test/java/com/blankj/utilcode/util/ZipUtilsTest.java
.../src/test/java/com/blankj/utilcode/util/ZipUtilsTest.java
+1
-1
未找到文件。
CHANGELOG.md
浏览文件 @
368926cc
*
`19/01/04`
[add] CacheDiskStaticUtils, CacheDoubleStaticUtils, CacheMemoryStaticUtils.
*
`19/01/03`
[add] SPStaticUtils.
*
`19/01/02`
[fix] LogUtils log object. Publish v1.22.10.
*
`19/01/01`
[add] GsonUtils.
*
`18/12/29`
[add] AntiShakeUtils and VibrateUtils. Publish v1.22.9.
...
...
README-CN.md
浏览文件 @
368926cc
...
...
@@ -41,7 +41,7 @@
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucSvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.22.1
0
-brightgreen.svg
[
aucSvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.22.1
1
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apiSvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
README.md
浏览文件 @
368926cc
...
...
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
[
logo
]:
https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
[
aucSvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.22.1
0
-brightgreen.svg
[
aucSvg
]:
https://img.shields.io/badge/AndroidUtilCode-v1.22.1
1
-brightgreen.svg
[
auc
]:
https://github.com/Blankj/AndroidUtilCode
[
apiSvg
]:
https://img.shields.io/badge/API-14+-brightgreen.svg
...
...
config.gradle
浏览文件 @
368926cc
...
...
@@ -5,8 +5,8 @@ ext {
compileSdkVersion
=
27
minSdkVersion
=
14
targetSdkVersion
=
27
versionCode
=
1
_022_01
0
versionName
=
'1.22.1
0
'
// E.g. 1.9.72 => 1,009,072
versionCode
=
1
_022_01
1
versionName
=
'1.22.1
1
'
// E.g. 1.9.72 => 1,009,072
bus
=
[
isDebug:
false
,
...
...
lib/base/build.gradle
浏览文件 @
368926cc
...
...
@@ -15,5 +15,5 @@ dependencies {
api
dep
.
free_proguard
api
'com.r0adkll:slidableactivity:2.0.5'
compileOnly
dep
.
leakcanary
.
android_no_op
// api 'com.blankj:utilcode:1.22.1
0
'
// api 'com.blankj:utilcode:1.22.1
1
'
}
\ No newline at end of file
utilcode/README-CN.md
浏览文件 @
368926cc
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.22.1
0
'
implementation
'com.blankj:utilcode:1.22.1
1
'
```
...
...
utilcode/README-STATIC-BUS.md
浏览文件 @
368926cc
...
...
@@ -27,7 +27,7 @@ apply plugin: "com.blankj.bus"
给 base 模块添加
[
AndroidUtilCode
](
https://github.com/Blankj/AndroidUtilCode
)
依赖:
```
groovy
api
"com.blankj:utilcode:1.22.1
0
"
api
"com.blankj:utilcode:1.22.1
1
"
```
比如 module0 中存在的
`Module0Activity.java`
,我们通常都是在它内部写一个
`start`
函数来启动它,现在我们给它添加
`@BusUtils.Subscribe`
注解,并给注解的
`name`
赋唯一值,要注意,函数务必要
`public static`
哦:
...
...
utilcode/README.md
浏览文件 @
368926cc
...
...
@@ -2,7 +2,7 @@
Gradle:
```
groovy
implementation
'com.blankj:utilcode:1.22.1
0
'
implementation
'com.blankj:utilcode:1.22.1
1
'
```
...
...
utilcode/lib/src/main/java/com/blankj/utilcode/util/JsonUtils.java
浏览文件 @
368926cc
//package com.blankj.utilcode.util;
//
//
//import org.json.JSONException;
//import org.json.JSONObject;
//
//public final class JsonUtils {
//
// private static byte TYPE_LONG = 0x01;
// private static byte TYPE_INT = 0x02;
//
// private JsonUtils() {
// throw new UnsupportedOperationException("u can't instantiate me...");
// }
//
// public static long getLong(final JSONObject jsonObject,
// final String key,
// final long defaultValue) {
// if (jsonObject == null || key == null || key.length() == 0) {
// return defaultValue;
// }
// try {
// return jsonObject.getLong(key);
// } catch (JSONException e) {
// return defaultValue;
// }
// }
//
// public static long getLong(final String json,
// final String key,
// final long defaultValue) {
// if (json == null || json.length() == 0
// || key == null || key.length() == 0) {
// return defaultValue;
// }
//
// try {
// return getLong(new JSONObject(json), key, defaultValue);
// } catch (JSONException e) {
// e.printStackTrace();
// return defaultValue;
// }
// }
//
// public static Object getType(final JSONObject jsonObject,
// final String key,
// final Object defaultValue,
// final byte type) {
// if (jsonObject == null || key == null || key.length() == 0) {
// return defaultValue;
// }
// try {
// if (type == TYPE_LONG) {
// return jsonObject.getLong(key);
// } else if (type == TYPE_INT) {
// return jsonObject.getInt(key);
// }
// } catch (JSONException e) {
// return defaultValue;
// }
// }
//
// public static long getLong(final String json,
// final String key,
// final long defaultValue) {
// if (json == null || json.length() == 0
// || key == null || key.length() == 0) {
// return defaultValue;
// }
//
// try {
// return getLong(new JSONObject(json), key, defaultValue);
// } catch (JSONException e) {
// e.printStackTrace();
// return defaultValue;
// }
// }
//
//}
package
com.blankj.utilcode.util
;
import
android.util.Log
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
public
final
class
JsonUtils
{
private
static
final
byte
TYPE_BOOLEAN
=
0x00
;
private
static
final
byte
TYPE_INT
=
0x01
;
private
static
final
byte
TYPE_LONG
=
0x02
;
private
static
final
byte
TYPE_DOUBLE
=
0x03
;
private
static
final
byte
TYPE_STRING
=
0x04
;
private
static
final
byte
TYPE_JSON_OBJECT
=
0x05
;
private
static
final
byte
TYPE_JSON_ARRAY
=
0x06
;
private
JsonUtils
()
{
throw
new
UnsupportedOperationException
(
"u can't instantiate me..."
);
}
public
static
boolean
getBoolean
(
final
JSONObject
jsonObject
,
final
String
key
)
{
return
getBoolean
(
jsonObject
,
key
,
false
);
}
public
static
boolean
getBoolean
(
final
JSONObject
jsonObject
,
final
String
key
,
final
boolean
defaultValue
)
{
return
getValueByType
(
jsonObject
,
key
,
defaultValue
,
TYPE_BOOLEAN
);
}
public
static
boolean
getBoolean
(
final
String
json
,
final
String
key
)
{
return
getBoolean
(
json
,
key
,
false
);
}
public
static
boolean
getBoolean
(
final
String
json
,
final
String
key
,
final
boolean
defaultValue
)
{
return
getValueByType
(
json
,
key
,
defaultValue
,
TYPE_BOOLEAN
);
}
public
static
int
getInt
(
final
JSONObject
jsonObject
,
final
String
key
)
{
return
getInt
(
jsonObject
,
key
,
-
1
);
}
public
static
int
getInt
(
final
JSONObject
jsonObject
,
final
String
key
,
final
int
defaultValue
)
{
return
getValueByType
(
jsonObject
,
key
,
defaultValue
,
TYPE_INT
);
}
public
static
int
getInt
(
final
String
json
,
final
String
key
)
{
return
getInt
(
json
,
key
,
-
1
);
}
public
static
int
getInt
(
final
String
json
,
final
String
key
,
final
int
defaultValue
)
{
return
getValueByType
(
json
,
key
,
defaultValue
,
TYPE_INT
);
}
public
static
long
getLong
(
final
JSONObject
jsonObject
,
final
String
key
)
{
return
getLong
(
jsonObject
,
key
,
-
1
);
}
public
static
long
getLong
(
final
JSONObject
jsonObject
,
final
String
key
,
final
long
defaultValue
)
{
return
getValueByType
(
jsonObject
,
key
,
defaultValue
,
TYPE_LONG
);
}
public
static
long
getLong
(
final
String
json
,
final
String
key
)
{
return
getLong
(
json
,
key
,
-
1
);
}
public
static
long
getLong
(
final
String
json
,
final
String
key
,
final
long
defaultValue
)
{
return
getValueByType
(
json
,
key
,
defaultValue
,
TYPE_LONG
);
}
public
static
double
getDouble
(
final
JSONObject
jsonObject
,
final
String
key
)
{
return
getDouble
(
jsonObject
,
key
,
-
1
);
}
public
static
double
getDouble
(
final
JSONObject
jsonObject
,
final
String
key
,
final
double
defaultValue
)
{
return
getValueByType
(
jsonObject
,
key
,
defaultValue
,
TYPE_DOUBLE
);
}
public
static
double
getDouble
(
final
String
json
,
final
String
key
)
{
return
getDouble
(
json
,
key
,
-
1
);
}
public
static
double
getDouble
(
final
String
json
,
final
String
key
,
final
double
defaultValue
)
{
return
getValueByType
(
json
,
key
,
defaultValue
,
TYPE_DOUBLE
);
}
public
static
String
getString
(
final
JSONObject
jsonObject
,
final
String
key
)
{
return
getString
(
jsonObject
,
key
,
""
);
}
public
static
String
getString
(
final
JSONObject
jsonObject
,
final
String
key
,
final
String
defaultValue
)
{
return
getValueByType
(
jsonObject
,
key
,
defaultValue
,
TYPE_STRING
);
}
public
static
String
getString
(
final
String
json
,
final
String
key
)
{
return
getString
(
json
,
key
,
""
);
}
public
static
String
getString
(
final
String
json
,
final
String
key
,
final
String
defaultValue
)
{
return
getValueByType
(
json
,
key
,
defaultValue
,
TYPE_STRING
);
}
public
static
JSONObject
getJSONObject
(
final
JSONObject
jsonObject
,
final
String
key
,
final
JSONObject
defaultValue
)
{
return
getValueByType
(
jsonObject
,
key
,
defaultValue
,
TYPE_JSON_OBJECT
);
}
public
static
JSONObject
getJSONObject
(
final
String
json
,
final
String
key
,
final
JSONObject
defaultValue
)
{
return
getValueByType
(
json
,
key
,
defaultValue
,
TYPE_JSON_OBJECT
);
}
public
static
JSONArray
getJSONArray
(
final
JSONObject
jsonObject
,
final
String
key
,
final
JSONArray
defaultValue
)
{
return
getValueByType
(
jsonObject
,
key
,
defaultValue
,
TYPE_JSON_ARRAY
);
}
public
static
JSONArray
getJSONArray
(
final
String
json
,
final
String
key
,
final
JSONArray
defaultValue
)
{
return
getValueByType
(
json
,
key
,
defaultValue
,
TYPE_JSON_ARRAY
);
}
private
static
<
T
>
T
getValueByType
(
final
JSONObject
jsonObject
,
final
String
key
,
final
T
defaultValue
,
final
byte
type
)
{
if
(
jsonObject
==
null
||
key
==
null
||
key
.
length
()
==
0
)
{
return
defaultValue
;
}
try
{
Object
ret
;
if
(
type
==
TYPE_BOOLEAN
)
{
ret
=
jsonObject
.
getBoolean
(
key
);
}
else
if
(
type
==
TYPE_INT
)
{
ret
=
jsonObject
.
getInt
(
key
);
}
else
if
(
type
==
TYPE_LONG
)
{
ret
=
jsonObject
.
getLong
(
key
);
}
else
if
(
type
==
TYPE_DOUBLE
)
{
ret
=
jsonObject
.
getDouble
(
key
);
}
else
if
(
type
==
TYPE_STRING
)
{
ret
=
jsonObject
.
getString
(
key
);
}
else
if
(
type
==
TYPE_JSON_OBJECT
)
{
ret
=
jsonObject
.
getJSONObject
(
key
);
}
else
if
(
type
==
TYPE_JSON_ARRAY
)
{
ret
=
jsonObject
.
getJSONArray
(
key
);
}
else
{
return
defaultValue
;
}
//noinspection unchecked
return
(
T
)
ret
;
}
catch
(
JSONException
e
)
{
Log
.
e
(
"JsonUtils"
,
"getValueByType: "
,
e
);
return
defaultValue
;
}
}
private
static
<
T
>
T
getValueByType
(
final
String
json
,
final
String
key
,
final
T
defaultValue
,
final
byte
type
)
{
if
(
json
==
null
||
json
.
length
()
==
0
||
key
==
null
||
key
.
length
()
==
0
)
{
return
defaultValue
;
}
try
{
return
getValueByType
(
new
JSONObject
(
json
),
key
,
defaultValue
,
type
);
}
catch
(
JSONException
e
)
{
Log
.
e
(
"JsonUtils"
,
"getValueByType: "
,
e
);
return
defaultValue
;
}
}
}
utilcode/lib/src/test/java/com/blankj/utilcode/util/CacheMemoryStaticUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertNull;
* desc : test CacheMemoryStaticUtils
* </pre>
*/
public
class
CacheMemoryStaticUtilsTest
{
public
class
CacheMemoryStaticUtilsTest
extends
BaseTest
{
private
CacheMemoryUtils
mCacheMemoryUtils
=
CacheMemoryUtils
.
getInstance
(
3
);
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/CacheMemoryUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertNull;
* desc : test CacheMemoryUtils
* </pre>
*/
public
class
CacheMemoryUtilsTest
{
public
class
CacheMemoryUtilsTest
extends
BaseTest
{
private
CacheMemoryUtils
mCacheMemoryUtils1
=
CacheMemoryUtils
.
getInstance
();
private
CacheMemoryUtils
mCacheMemoryUtils2
=
CacheMemoryUtils
.
getInstance
(
3
);
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/ConvertUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertTrue;
* desc : test ConvertUtils
* </pre>
*/
public
class
ConvertUtilsTest
{
public
class
ConvertUtilsTest
extends
BaseTest
{
private
byte
[]
mBytes
=
new
byte
[]{
0x00
,
0x08
,
(
byte
)
0xdb
,
0x33
,
0x45
,
(
byte
)
0xab
,
0x02
,
0x23
};
private
String
hexString
=
"0008DB3345AB0223"
;
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/FileIOUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -17,7 +17,7 @@ import static com.blankj.utilcode.util.TestConfig.PATH_TEMP;
* desc : test FileIOUtils
* </pre>
*/
public
class
FileIOUtilsTest
{
public
class
FileIOUtilsTest
extends
BaseTest
{
@Test
public
void
writeFileFromIS
()
throws
Exception
{
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/FileUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertTrue;
* desc : test FileUtils
* </pre>
*/
public
class
FileUtilsTest
{
public
class
FileUtilsTest
extends
BaseTest
{
private
FileFilter
mFilter
=
new
FileFilter
()
{
@Override
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/GsonUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -12,7 +12,7 @@ import org.junit.Test;
* desc : test GsonUtils
* </pre>
*/
public
class
GsonUtilsTest
{
public
class
GsonUtilsTest
extends
BaseTest
{
@Test
public
void
getGson
()
{
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/ObjectUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -8,9 +8,6 @@ import android.util.SparseIntArray;
import
android.util.SparseLongArray
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.robolectric.RobolectricTestRunner
;
import
org.robolectric.annotation.Config
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
...
...
@@ -26,9 +23,7 @@ import static org.junit.Assert.assertTrue;
* desc : test ObjectUtils
* </pre>
*/
@RunWith
(
RobolectricTestRunner
.
class
)
@Config
(
manifest
=
Config
.
NONE
,
sdk
=
23
)
public
class
ObjectUtilsTest
{
public
class
ObjectUtilsTest
extends
BaseTest
{
@Test
public
void
isEmpty
()
{
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/RegexUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -15,7 +15,7 @@ import static org.junit.Assert.assertTrue;
* desc : test RegexUtils
* </pre>
*/
public
class
RegexUtilsTest
{
public
class
RegexUtilsTest
extends
BaseTest
{
@Test
public
void
isMobileSimple
()
{
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/StringUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue;
* desc : test StringUtils
* </pre>
*/
public
class
StringUtilsTest
{
public
class
StringUtilsTest
extends
BaseTest
{
@Test
public
void
isEmpty
()
{
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/ThreadUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -14,7 +14,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* desc :
* </pre>
*/
public
class
ThreadUtilsTest
{
public
class
ThreadUtilsTest
extends
BaseTest
{
@Test
public
void
executeByFixed
()
throws
Exception
{
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/TimeUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertTrue;
* desc : test TimeUtils
* </pre>
*/
public
class
TimeUtilsTest
{
public
class
TimeUtilsTest
extends
BaseTest
{
private
final
DateFormat
defaultFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
getDefault
());
private
final
DateFormat
mFormat
=
new
SimpleDateFormat
(
"yyyy MM dd HH:mm:ss"
,
Locale
.
getDefault
());
...
...
utilcode/lib/src/test/java/com/blankj/utilcode/util/ZipUtilsTest.java
浏览文件 @
368926cc
...
...
@@ -19,7 +19,7 @@ import static junit.framework.TestCase.assertTrue;
* desc : test ZipUtils
* </pre>
*/
public
class
ZipUtilsTest
{
public
class
ZipUtilsTest
extends
BaseTest
{
private
String
zipFile
=
PATH_TEMP
+
"zipFile.zip"
;
private
String
zipFiles
=
PATH_TEMP
+
"zipFiles.zip"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录