Skip to content

Commit 9710722

Browse files
committed
see 01/31 log
1 parent cc7a785 commit 9710722

File tree

12 files changed

+88
-22
lines changed

12 files changed

+88
-22
lines changed

README-CN.md

Lines changed: 1 addition & 1 deletion
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.12.3-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.12.4-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this ptoject helps you a lot, and you would like to support this ptoject's fu
4141

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

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

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

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dependencies {
6767
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
6868
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"
6969

70-
// implementation 'com.blankj:utilcode:1.12.3'
70+
// implementation 'com.blankj:utilcode:1.12.4'
7171
}
7272

7373

app/src/main/java/com/blankj/androidutilcode/feature/core/activity/ActivityActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ public void onWidgetClick(View view) {
249249

250250
private Bundle getOption(int type) {
251251
switch (type) {
252-
default:
253252
case 0:
254253
return ActivityOptionsCompat.makeCustomAnimation(this,
255254
R.anim.slide_in_right_1000,
@@ -277,6 +276,8 @@ private Bundle getOption(int type) {
277276
viewSharedElement,
278277
getString(R.string.activity_shared_element))
279278
.toBundle();
279+
default:
280+
return null;
280281
}
281282
}
282283
}

app/src/main/java/com/blankj/androidutilcode/feature/core/screen/ScreenActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ public void initView(Bundle savedInstanceState, View view) {
6161
.append("isTablet: " + ScreenUtils.isTablet())
6262
.create()
6363
);
64-
65-
6664
}
6765

6866
@Override

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ ext {
3232
min_sdk_version = 14
3333
target_sdk_version = 23
3434

35-
version_code = 1_012_003
36-
version_name = '1.12.3'// E.g 1.9.72 => 1,009,072
35+
version_code = 1_012_004
36+
version_name = '1.12.4'// E.g 1.9.72 => 1,009,072
3737

3838
// App dependencies
3939
support_version = '26.1.0'
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.blankj.subutil.util;
2+
3+
import java.io.ByteArrayInputStream;
4+
import java.io.ByteArrayOutputStream;
5+
import java.io.IOException;
6+
import java.io.ObjectInputStream;
7+
import java.io.ObjectOutputStream;
8+
import java.io.Serializable;
9+
10+
/**
11+
* <pre>
12+
* author: Blankj
13+
* blog : http://blankj.com
14+
* time : 2018/01/30
15+
* desc : 克隆相关工具类
16+
* </pre>
17+
*/
18+
public final class CloneUtils {
19+
20+
public static <T> T deepClone(final Serializable data) {
21+
if (data == null) return null;
22+
return (T) bytes2Object(serializable2Bytes((Serializable) data));
23+
}
24+
25+
private static byte[] serializable2Bytes(final Serializable serializable) {
26+
if (serializable == null) return null;
27+
ByteArrayOutputStream baos;
28+
ObjectOutputStream oos = null;
29+
try {
30+
oos = new ObjectOutputStream(baos = new ByteArrayOutputStream());
31+
oos.writeObject(serializable);
32+
return baos.toByteArray();
33+
} catch (Exception e) {
34+
e.printStackTrace();
35+
return null;
36+
} finally {
37+
try {
38+
if (oos != null) {
39+
oos.close();
40+
}
41+
} catch (IOException e) {
42+
e.printStackTrace();
43+
}
44+
}
45+
}
46+
47+
private static Object bytes2Object(final byte[] bytes) {
48+
if (bytes == null) return null;
49+
ObjectInputStream ois = null;
50+
try {
51+
ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
52+
return ois.readObject();
53+
} catch (Exception e) {
54+
e.printStackTrace();
55+
return null;
56+
} finally {
57+
try {
58+
if (ois != null) {
59+
ois.close();
60+
}
61+
} catch (IOException e) {
62+
e.printStackTrace();
63+
}
64+
}
65+
}
66+
}

update_log.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
* 18/01/27 修复 ToastUtils 默认样式问题,发布 1.12.2,新增 DeviceUtils#getSDKVersionName,发布 1.12.3
1+
* 18/01/31 修复 default 相关的逻辑错误,发布 1.12.4
2+
* 18/01/28 修复 ToastUtils 默认样式问题,发布 1.12.2,新增 DeviceUtils#getSDKVersionName,发布 1.12.3
23
* 18/01/27 修复 PermissionUtils 某些机型闪烁问题,发布 1.12.1
34
* 18/01/17 完善 ReflectUtils 及 单元测试,发布 1.12.0 版本
45
* 18/01/16 完善 ReflectUtils 及 单元测试

utilcode/README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
compile 'com.blankj:utilcode:1.12.3'
5+
compile 'com.blankj:utilcode:1.12.4'
66
```
77

88

utilcode/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
compile 'com.blankj:utilcode:1.12.3'
5+
compile 'com.blankj:utilcode:1.12.4'
66
```
77

88

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -576,33 +576,32 @@ public static Bitmap rotate(final Bitmap src,
576576

577577
/**
578578
* 获取图片旋转角度
579+
* <p>返回 -1 表示异常</p>
579580
*
580581
* @param filePath 文件路径
581582
* @return 旋转角度
582583
*/
583584
public static int getRotateDegree(final String filePath) {
584-
int degree = 0;
585585
try {
586586
ExifInterface exifInterface = new ExifInterface(filePath);
587587
int orientation = exifInterface.getAttributeInt(
588588
ExifInterface.TAG_ORIENTATION,
589-
ExifInterface.ORIENTATION_NORMAL);
589+
ExifInterface.ORIENTATION_NORMAL
590+
);
590591
switch (orientation) {
591-
default:
592592
case ExifInterface.ORIENTATION_ROTATE_90:
593-
degree = 90;
594-
break;
593+
return 90;
595594
case ExifInterface.ORIENTATION_ROTATE_180:
596-
degree = 180;
597-
break;
595+
return 180;
598596
case ExifInterface.ORIENTATION_ROTATE_270:
599-
degree = 270;
600-
break;
597+
return 270;
598+
default:
599+
return 0;
601600
}
602601
} catch (IOException e) {
603602
e.printStackTrace();
603+
return -1;
604604
}
605-
return degree;
606605
}
607606

608607
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ public static boolean isPortrait() {
150150
*/
151151
public static int getScreenRotation(@NonNull final Activity activity) {
152152
switch (activity.getWindowManager().getDefaultDisplay().getRotation()) {
153-
default:
154153
case Surface.ROTATION_0:
155154
return 0;
156155
case Surface.ROTATION_90:
@@ -159,6 +158,8 @@ public static int getScreenRotation(@NonNull final Activity activity) {
159158
return 180;
160159
case Surface.ROTATION_270:
161160
return 270;
161+
default:
162+
return 0;
162163
}
163164
}
164165

0 commit comments

Comments
 (0)