Skip to content

Commit 9c98177

Browse files
committed
see 09/07 log
1 parent aeae30a commit 9c98177

File tree

10 files changed

+175
-139
lines changed

10 files changed

+175
-139
lines changed

app/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ android {
2929

3030
buildTypes {
3131
debug {
32-
minifyEnabled false
32+
minifyEnabled true
3333
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3434
}
3535
release {
@@ -77,7 +77,9 @@ dependencies {
7777
releaseCompile leakCanary
7878
testCompile leakCanary
7979

80-
// compile 'com.blankj:utilcode:1.8.4'
80+
compile 'com.tencent.mars:mars-core:1.2.0'
81+
82+
// compile 'com.blankj:utilcode:1.9.0'
8183
}
8284

8385

app/proguard-rules.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18-

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="com.blankj.androidutilcode">
45

56
<!--bar-->
@@ -50,6 +51,8 @@
5051
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
5152
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
5253

54+
<uses-sdk tools:overrideLibrary="com.tencent.mars"/>
55+
5356
<application
5457
android:name=".UtilsApp"
5558
android:allowBackup="false"
@@ -63,7 +66,6 @@
6366
</intent-filter>
6467
</activity>
6568

66-
6769
<!--core-->
6870
<activity
6971
android:name=".core.main.CoreUtilActivity" />

utilcode/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ android {
3737
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3838
}
3939
release {
40-
minifyEnabled false
40+
minifyEnabled true
4141
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
4242
}
4343
}

utilcode/proguard-rules.pro

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,4 @@
1414
# class:
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
17-
#}
18-
19-
-keep class com.blankj.utilcode.** { *; }
20-
-keepclassmembers class com.blankj.utilcode.** { *; }
21-
-dontwarn com.blankj.utilcode.**
17+
#}

utilcode/src/test/java/com/blankj/utilcode/util/CacheUtilsTest.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,25 @@ public void getJSONArray() throws Exception {
145145

146146
@Test
147147
public void getBitmap() throws Exception {
148-
Assert.assertTrue(mCacheUtils1.getString("bitmap1").equals("Bitmap (100 x 100) compressed as PNG with quality 100"));
149-
Assert.assertTrue(mCacheUtils1.getString("bitmap1", null).equals("Bitmap (100 x 100) compressed as PNG with quality 100"));
148+
String bitmapString = "Bitmap (100 x 100) compressed as PNG with quality 100";
149+
Assert.assertTrue(mCacheUtils1.getString("bitmap1").equals(bitmapString));
150+
Assert.assertTrue(mCacheUtils1.getString("bitmap1", null).equals(bitmapString));
150151
Assert.assertNull(mCacheUtils1.getString("bitmap2", null));
151152

152-
Assert.assertTrue(mCacheUtils2.getString("bitmap2").equals("Bitmap (100 x 100) compressed as PNG with quality 100"));
153-
Assert.assertTrue(mCacheUtils2.getString("bitmap2", null).equals("Bitmap (100 x 100) compressed as PNG with quality 100"));
153+
Assert.assertTrue(mCacheUtils2.getString("bitmap2").equals(bitmapString));
154+
Assert.assertTrue(mCacheUtils2.getString("bitmap2", null).equals(bitmapString));
154155
Assert.assertNull(mCacheUtils2.getString("bitmap1", null));
155156
}
156157

157158
@Test
158159
public void getDrawable() throws Exception {
159-
Assert.assertTrue(mCacheUtils1.getString("drawable1").equals("Bitmap (100 x 100) compressed as PNG with quality 100"));
160-
Assert.assertTrue(mCacheUtils1.getString("drawable1", null).equals("Bitmap (100 x 100) compressed as PNG with quality 100"));
160+
String bitmapString = "Bitmap (100 x 100) compressed as PNG with quality 100";
161+
Assert.assertTrue(mCacheUtils1.getString("drawable1").equals(bitmapString));
162+
Assert.assertTrue(mCacheUtils1.getString("drawable1", null).equals(bitmapString));
161163
Assert.assertNull(mCacheUtils1.getString("drawable2", null));
162164

163-
Assert.assertTrue(mCacheUtils2.getString("drawable2").equals("Bitmap (100 x 100) compressed as PNG with quality 100"));
164-
Assert.assertTrue(mCacheUtils2.getString("drawable2", null).equals("Bitmap (100 x 100) compressed as PNG with quality 100"));
165+
Assert.assertTrue(mCacheUtils2.getString("drawable2").equals(bitmapString));
166+
Assert.assertTrue(mCacheUtils2.getString("drawable2", null).equals(bitmapString));
165167
Assert.assertNull(mCacheUtils2.getString("drawable1", null));
166168
}
167169

@@ -348,7 +350,9 @@ public void setClassName(String className) {
348350

349351
@Override
350352
public boolean equals(Object obj) {
351-
return obj instanceof SerializableTest && ((SerializableTest) obj).author.equals(author) && ((SerializableTest) obj).className.equals(className);
353+
return obj instanceof SerializableTest
354+
&& ((SerializableTest) obj).author.equals(author)
355+
&& ((SerializableTest) obj).className.equals(className);
352356
}
353357
}
354358
}

utilcode/src/test/java/com/blankj/utilcode/util/ConvertUtilsTest.java

Lines changed: 84 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import com.blankj.utilcode.constant.MemoryConstants;
55
import com.blankj.utilcode.constant.TimeConstants;
66

7+
import org.junit.Assert;
78
import org.junit.Test;
89

9-
import static com.blankj.utilcode.util.ConvertUtils.*;
10-
import static com.google.common.truth.Truth.assertThat;
10+
import java.util.Arrays;
1111

1212

1313
/**
@@ -20,75 +20,119 @@
2020
*/
2121
public class ConvertUtilsTest {
2222

23-
byte[] mBytes = new byte[]{0x00, 0x08, (byte) 0xdb, 0x33, 0x45, (byte) 0xab, 0x02, 0x23};
24-
String hexString = "0008DB3345AB0223";
23+
private byte[] mBytes = new byte[]{0x00, 0x08, (byte) 0xdb, 0x33, 0x45, (byte) 0xab, 0x02, 0x23};
24+
private String hexString = "0008DB3345AB0223";
2525

26-
@Test
27-
public void testBytes2HexString() throws Exception {
28-
assertThat(bytes2HexString(mBytes)).isEqualTo(hexString);
29-
}
26+
private char[] mChars1 = new char[]{'0', '1', '2'};
27+
private byte[] mBytes1 = new byte[]{48, 49, 50};
3028

3129
@Test
32-
public void testHexString2Bytes() throws Exception {
33-
assertThat(hexString2Bytes(hexString)).isEqualTo(mBytes);
30+
public void bytes2HexString() throws Exception {
31+
Assert.assertEquals(
32+
hexString,
33+
ConvertUtils.bytes2HexString(mBytes)
34+
);
3435
}
3536

36-
char[] mChars1 = new char[]{'0', '1', '2'};
37-
byte[] mBytes1 = new byte[]{48, 49, 50};
38-
3937
@Test
40-
public void testChars2Bytes() throws Exception {
41-
assertThat(chars2Bytes(mChars1)).isEqualTo(mBytes1);
38+
public void hexString2Bytes() throws Exception {
39+
Assert.assertTrue(
40+
Arrays.equals(
41+
mBytes,
42+
ConvertUtils.hexString2Bytes(hexString)
43+
)
44+
);
4245
}
4346

4447
@Test
45-
public void testBytes2Chars() throws Exception {
46-
assertThat(bytes2Chars(mBytes1)).isEqualTo(mChars1);
48+
public void chars2Bytes() throws Exception {
49+
Assert.assertTrue(
50+
Arrays.equals(
51+
mBytes1,
52+
ConvertUtils.chars2Bytes(mChars1)
53+
)
54+
);
4755
}
4856

4957
@Test
50-
public void testByte2Unit() throws Exception {
51-
assertThat(byte2MemorySize(MemoryConstants.GB, MemoryConstants.MB) - 1024).isWithin(0.001);
58+
public void bytes2Chars() throws Exception {
59+
Assert.assertTrue(
60+
Arrays.equals(
61+
mChars1,
62+
ConvertUtils.bytes2Chars(mBytes1)
63+
)
64+
);
5265
}
5366

5467
@Test
55-
public void testByte2FitSize() throws Exception {
56-
assertThat(byte2FitMemorySize(1024 * 1024 * 3 + 1024 * 100)).isEqualTo("3.098MB");
68+
public void byte2MemorySize() throws Exception {
69+
Assert.assertEquals(
70+
1024,
71+
ConvertUtils.byte2MemorySize(MemoryConstants.GB, MemoryConstants.MB),
72+
0.001
73+
);
5774
}
5875

5976
@Test
60-
public void testMillis2FitTimeSpan() throws Exception {
61-
long millis = TimeConstants.DAY * 6 + TimeConstants.HOUR * 6
62-
+ TimeConstants.MIN * 6 + TimeConstants.SEC * 6 + 6;
63-
System.out.println(millis2FitTimeSpan(millis, 7));
64-
System.out.println(millis2FitTimeSpan(millis, 4));
65-
System.out.println(millis2FitTimeSpan(millis, 3));
66-
System.out.println(millis2FitTimeSpan(millis * 4, 5));
77+
public void byte2FitMemorySize() throws Exception {
78+
Assert.assertEquals(
79+
"3.098MB",
80+
ConvertUtils.byte2FitMemorySize(1024 * 1024 * 3 + 1024 * 100)
81+
);
6782
}
6883

6984
@Test
70-
public void testBytes2Bits() throws Exception {
71-
System.out.println(bytes2Bits(new byte[]{0x7F, (byte) 0xFA}));
85+
public void millis2FitTimeSpan() throws Exception {
86+
long millis = 6 * TimeConstants.DAY
87+
+ 6 * TimeConstants.HOUR
88+
+ 6 * TimeConstants.MIN
89+
+ 6 * TimeConstants.SEC
90+
+ 6;
91+
Assert.assertEquals(
92+
"6天6小时6分钟6秒6毫秒",
93+
ConvertUtils.millis2FitTimeSpan(millis, 7)
94+
);
95+
Assert.assertEquals(
96+
"6天6小时6分钟6秒",
97+
ConvertUtils.millis2FitTimeSpan(millis, 4)
98+
);
99+
Assert.assertEquals(
100+
"6天6小时6分钟",
101+
ConvertUtils.millis2FitTimeSpan(millis, 3)
102+
);
103+
Assert.assertEquals(
104+
"25天24分钟24秒24毫秒",
105+
ConvertUtils.millis2FitTimeSpan(millis * 4, 5)
106+
);
72107
}
73108

74109
@Test
75-
public void testBits2Bytes() throws Exception {
76-
System.out.println(bytes2HexString(bits2Bytes("111111111111010")));
110+
public void bytes2Bits_bits2Bytes() throws Exception {
111+
Assert.assertEquals(
112+
"0111111111111010",
113+
ConvertUtils.bytes2Bits(new byte[]{0x7F, (byte) 0xFA})
114+
);
115+
Assert.assertEquals(
116+
"0111111111111010",
117+
ConvertUtils.bytes2Bits(ConvertUtils.bits2Bytes("111111111111010"))
118+
);
77119
}
78120

79121
@Test
80-
public void testInputStream2BytesAndBytes2InputStream() throws Exception {
122+
public void inputStream2Bytes_bytes2InputStream() throws Exception {
81123
String string = "this is test string";
82-
assertThat(new String(inputStream2Bytes(
83-
bytes2InputStream(string.getBytes("UTF-8")))))
84-
.isEqualTo(string);
124+
Assert.assertEquals(
125+
string.getBytes("UTF-8"),
126+
ConvertUtils.inputStream2Bytes(ConvertUtils.bytes2InputStream(string.getBytes("UTF-8")))
127+
);
85128
}
86129

87130
@Test
88-
public void testInputStream2StringAndString2InputStream() throws Exception {
131+
public void inputStream2String_string2InputStream() throws Exception {
89132
String string = "this is test string";
90-
assertThat(inputStream2String(
91-
string2InputStream(string, "UTF-8")
92-
, "UTF-8")).isEqualTo(string);
133+
Assert.assertEquals(
134+
string,
135+
ConvertUtils.inputStream2String(ConvertUtils.string2InputStream(string, "UTF-8"), "UTF-8")
136+
);
93137
}
94138
}

utilcode/src/test/java/com/blankj/utilcode/util/EmptyUtilsTest.java

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import android.annotation.TargetApi;
44
import android.os.Build;
5+
import android.support.v4.util.LongSparseArray;
6+
import android.support.v4.util.SimpleArrayMap;
57
import android.util.SparseArray;
68
import android.util.SparseBooleanArray;
79
import android.util.SparseIntArray;
810
import android.util.SparseLongArray;
911

12+
import org.junit.Assert;
1013
import org.junit.Test;
1114
import org.junit.runner.RunWith;
1215
import org.robolectric.RobolectricTestRunner;
@@ -15,8 +18,6 @@
1518
import java.util.HashMap;
1619
import java.util.LinkedList;
1720

18-
import static com.google.common.truth.Truth.assertThat;
19-
2021
/**
2122
* <pre>
2223
* author: Blankj
@@ -26,7 +27,7 @@
2627
* </pre>
2728
*/
2829
@RunWith(RobolectricTestRunner.class)
29-
@Config(manifest = Config.NONE , sdk = 23)
30+
@Config(manifest = Config.NONE, sdk = 23)
3031
public class EmptyUtilsTest {
3132

3233
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@@ -37,32 +38,41 @@ public void isEmpty() throws Exception {
3738
int[][] arr = new int[][]{};
3839
int[] arr1 = null;
3940
LinkedList<Integer> list = new LinkedList<>();
40-
HashMap<String,Integer> map = new HashMap<>();
41+
HashMap<String, Integer> map = new HashMap<>();
42+
SimpleArrayMap<String, Integer> sam = new SimpleArrayMap<>();
4143
SparseArray<String> sa = new SparseArray<>();
4244
SparseBooleanArray sba = new SparseBooleanArray();
4345
SparseIntArray sia = new SparseIntArray();
4446
SparseLongArray sla = new SparseLongArray();
47+
LongSparseArray<String> lsa = new LongSparseArray<>();
48+
android.util.LongSparseArray<String> lsa4 = new android.util.LongSparseArray<>();
4549

46-
assertThat(EmptyUtils.isEmpty(string)).isTrue();
47-
assertThat(EmptyUtils.isEmpty(string1)).isFalse();
48-
assertThat(EmptyUtils.isEmpty(arr)).isTrue();
49-
assertThat(EmptyUtils.isEmpty(arr1)).isTrue();
50-
assertThat(EmptyUtils.isEmpty(list)).isTrue();
51-
assertThat(EmptyUtils.isEmpty(map)).isTrue();
52-
assertThat(EmptyUtils.isEmpty(sa)).isTrue();
53-
assertThat(EmptyUtils.isEmpty(sba)).isTrue();
54-
assertThat(EmptyUtils.isEmpty(sia)).isTrue();
55-
assertThat(EmptyUtils.isEmpty(sla)).isTrue();
50+
Assert.assertTrue(EmptyUtils.isEmpty(string));
51+
Assert.assertFalse(EmptyUtils.isEmpty(string1));
52+
Assert.assertTrue(EmptyUtils.isEmpty(arr));
53+
Assert.assertTrue(EmptyUtils.isEmpty(arr1));
54+
Assert.assertTrue(EmptyUtils.isEmpty(list));
55+
Assert.assertTrue(EmptyUtils.isEmpty(map));
56+
Assert.assertTrue(EmptyUtils.isEmpty(sam));
57+
Assert.assertTrue(EmptyUtils.isEmpty(sa));
58+
Assert.assertTrue(EmptyUtils.isEmpty(sba));
59+
Assert.assertTrue(EmptyUtils.isEmpty(sia));
60+
Assert.assertTrue(EmptyUtils.isEmpty(sla));
61+
Assert.assertTrue(EmptyUtils.isEmpty(lsa));
62+
Assert.assertTrue(EmptyUtils.isEmpty(lsa4));
5663

57-
assertThat(!EmptyUtils.isNotEmpty(string)).isTrue();
58-
assertThat(!EmptyUtils.isNotEmpty(string1)).isFalse();
59-
assertThat(!EmptyUtils.isNotEmpty(arr)).isTrue();
60-
assertThat(!EmptyUtils.isNotEmpty(arr1)).isTrue();
61-
assertThat(!EmptyUtils.isNotEmpty(list)).isTrue();
62-
assertThat(!EmptyUtils.isNotEmpty(map)).isTrue();
63-
assertThat(!EmptyUtils.isNotEmpty(sa)).isTrue();
64-
assertThat(!EmptyUtils.isNotEmpty(sba)).isTrue();
65-
assertThat(!EmptyUtils.isNotEmpty(sia)).isTrue();
66-
assertThat(!EmptyUtils.isNotEmpty(sla)).isTrue();
64+
Assert.assertTrue(!EmptyUtils.isNotEmpty(string));
65+
Assert.assertFalse(!EmptyUtils.isNotEmpty(string1));
66+
Assert.assertTrue(!EmptyUtils.isNotEmpty(arr));
67+
Assert.assertTrue(!EmptyUtils.isNotEmpty(arr1));
68+
Assert.assertTrue(!EmptyUtils.isNotEmpty(list));
69+
Assert.assertTrue(!EmptyUtils.isNotEmpty(map));
70+
Assert.assertTrue(!EmptyUtils.isNotEmpty(sam));
71+
Assert.assertTrue(!EmptyUtils.isNotEmpty(sa));
72+
Assert.assertTrue(!EmptyUtils.isNotEmpty(sba));
73+
Assert.assertTrue(!EmptyUtils.isNotEmpty(sia));
74+
Assert.assertTrue(!EmptyUtils.isNotEmpty(sla));
75+
Assert.assertTrue(!EmptyUtils.isNotEmpty(lsa));
76+
Assert.assertTrue(!EmptyUtils.isNotEmpty(lsa4));
6777
}
6878
}

0 commit comments

Comments
 (0)