File tree Expand file tree Collapse file tree 5 files changed +57
-3
lines changed
androidframework/src/main/java/com/blankj/androidframework/utils Expand file tree Collapse file tree 5 files changed +57
-3
lines changed Original file line number Diff line number Diff line change 5757> - 设置透明状态栏(api >= 19方可使用) * setTransparentStatusBar*
5858> - 隐藏状态栏(注释萌萌哒) * hideStatusBar*
5959> - 获取状态栏高度 * getStatusBarHeight*
60+ > - 判断状态栏是否存在 * isStatusBarExists*
6061> - 获取ActionBar高度 * getActionBarHeight*
6162> - 设置屏幕为横屏(注释萌萌哒) * setLandscape*
6263> - 获取屏幕截图 * snapShotWithStatusBar* 、* snapShotWithoutStatusBar*
100101#### 2016/08/02 新增隐藏状态栏,注释更加全面,工具类已封装,写的时候真的是一个一个测试过去的,宝宝心里苦
101102#### 2016/08/03 修复在onCreate中获取view尺寸的bug,MD5和SHA的Bug修复完成(在此感谢ssyijiu)
102103#### 2016/08/04 新增时间工具类(在此感谢yi520000给的补充),手机正则分简单和精确(在此感谢MIkeeJY),新增判断是否锁屏,注释分段落,目录按首字母排序
103- #### 2016/08/05 加密新增MD5盐加密,完善NetworkUtils
104+ #### 2016/08/05 加密新增MD5盐加密,完善NetworkUtils,新增判断状态栏是否存在(在此感谢tiandawu)
104105
105106
106107##[ 关于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) {
1717 * <p >需与上面的isPhone一起使用
1818 * <p >需添加权限<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
1919 */
20- public static String getDeviceIMEI (Context context) {
20+ public static String getPhoneIMEI (Context context) {
2121 String deviceId;
2222 if (isPhone(context)) {
2323 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) {
7474}
7575```
7676
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+
7794### 获取ActionBar高度
7895``` java
7996/**
@@ -149,3 +166,25 @@ public static boolean isScreenLock(Context context) {
149166 return km. inKeyguardRestrictedInputMode();
150167}
151168```
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) {
8787 return result ;
8888 }
8989
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+
90104 /**
91105 * 获取ActionBar高度
92106 */
Original file line number Diff line number Diff line change 88#### 2016/08/02 新增隐藏状态栏,注释更加全面,工具类已封装,写的时候真的是一个一个测试过去的,宝宝心里苦
99#### 2016/08/03 修复在onCreate中获取view尺寸的bug,MD5和SHA的Bug修复完成(在此感谢ssyijiu)
1010#### 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