File tree 5 files changed +57
-3
lines changed
androidframework/src/main/java/com/blankj/androidframework/utils
5 files changed +57
-3
lines changed Original file line number Diff line number Diff line change 57
57
> - 设置透明状态栏(api >= 19方可使用) * setTransparentStatusBar*
58
58
> - 隐藏状态栏(注释萌萌哒) * hideStatusBar*
59
59
> - 获取状态栏高度 * getStatusBarHeight*
60
+ > - 判断状态栏是否存在 * isStatusBarExists*
60
61
> - 获取ActionBar高度 * getActionBarHeight*
61
62
> - 设置屏幕为横屏(注释萌萌哒) * setLandscape*
62
63
> - 获取屏幕截图 * snapShotWithStatusBar* 、* snapShotWithoutStatusBar*
100
101
#### 2016/08/02 新增隐藏状态栏,注释更加全面,工具类已封装,写的时候真的是一个一个测试过去的,宝宝心里苦
101
102
#### 2016/08/03 修复在onCreate中获取view尺寸的bug,MD5和SHA的Bug修复完成(在此感谢ssyijiu)
102
103
#### 2016/08/04 新增时间工具类(在此感谢yi520000给的补充),手机正则分简单和精确(在此感谢MIkeeJY),新增判断是否锁屏,注释分段落,目录按首字母排序
103
- #### 2016/08/05 加密新增MD5盐加密,完善NetworkUtils
104
+ #### 2016/08/05 加密新增MD5盐加密,完善NetworkUtils,新增判断状态栏是否存在(在此感谢tiandawu)
104
105
105
106
106
107
##[ 关于Blankj] ( http://blankj.com/about )
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public static boolean isPhone(Context context) {
17
17
* <p >需与上面的isPhone一起使用
18
18
* <p >需添加权限<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
19
19
*/
20
- public static String getDeviceIMEI (Context context) {
20
+ public static String getPhoneIMEI (Context context) {
21
21
String deviceId;
22
22
if (isPhone(context)) {
23
23
TelephonyManager tm = (TelephonyManager ) context. getSystemService(Context . TELEPHONY_SERVICE );
Original file line number Diff line number Diff line change @@ -74,6 +74,23 @@ public static int getStatusBarHeight(Context context) {
74
74
}
75
75
```
76
76
77
+ ### 判断状态栏是否存在
78
+ ``` java
79
+ /**
80
+ * 判断状态栏是否存在
81
+ *
82
+ * @param activity
83
+ * @return <ul >
84
+ * <li >true: 存在 </li>
85
+ * <li >false: 不存在</li>
86
+ * </ul>
87
+ */
88
+ public static boolean isStatusBarExists(Activity activity) {
89
+ WindowManager . LayoutParams params = activity. getWindow(). getAttributes();
90
+ return (params. flags & LayoutParams . FLAG_FULLSCREEN ) != LayoutParams . FLAG_FULLSCREEN ;
91
+ }
92
+ ```
93
+
77
94
### 获取ActionBar高度
78
95
``` java
79
96
/**
@@ -149,3 +166,25 @@ public static boolean isScreenLock(Context context) {
149
166
return km. inKeyguardRestrictedInputMode();
150
167
}
151
168
```
169
+
170
+ ***
171
+ # 尺寸相关
172
+ ### dp与px转换
173
+ ``` java
174
+ /**
175
+ * dp转px
176
+ */
177
+ public static int dp2px(Context context, float dpValue) {
178
+ final float scale = context. getResources(). getDisplayMetrics(). density;
179
+ return (int ) (dpValue * scale + 0.5f );
180
+ }
181
+
182
+ /**
183
+ * px转dp
184
+ */
185
+ public static int px2dp(Context context, float pxValue) {
186
+ final float scale = context. getResources(). getDisplayMetrics(). density;
187
+ return (int ) (pxValue / scale + 0.5f );
188
+ }
189
+ ```
190
+
Original file line number Diff line number Diff line change @@ -87,6 +87,20 @@ public static int getStatusBarHeight(Context context) {
87
87
return result ;
88
88
}
89
89
90
+ /**
91
+ * 判断状态栏是否存在
92
+ *
93
+ * @param activity
94
+ * @return <ul>
95
+ * <li>true: 存在 </li>
96
+ * <li>false: 不存在</li>
97
+ * </ul>
98
+ */
99
+ public static boolean isStatusBarExists (Activity activity ) {
100
+ WindowManager .LayoutParams params = activity .getWindow ().getAttributes ();
101
+ return (params .flags & LayoutParams .FLAG_FULLSCREEN ) != LayoutParams .FLAG_FULLSCREEN ;
102
+ }
103
+
90
104
/**
91
105
* 获取ActionBar高度
92
106
*/
Original file line number Diff line number Diff line change 8
8
#### 2016/08/02 新增隐藏状态栏,注释更加全面,工具类已封装,写的时候真的是一个一个测试过去的,宝宝心里苦
9
9
#### 2016/08/03 修复在onCreate中获取view尺寸的bug,MD5和SHA的Bug修复完成(在此感谢ssyijiu)
10
10
#### 2016/08/04 新增时间工具类(在此感谢yi520000给的补充),手机正则分简单和精确(在此感谢MIkeeJY),新增判断是否锁屏,注释分段落,目录按首字母排序
11
- #### 2016/08/05 加密新增MD5盐加密,完善NetworkUtils
11
+ #### 2016/08/05 加密新增MD5盐加密,完善NetworkUtils,新增判断状态栏是否存在(在此感谢tiandawu)
You can’t perform that action at this time.
0 commit comments