|
|
@@ -3,6 +3,7 @@ package com.adealink.frame.util
|
|
|
import android.app.Activity
|
|
|
import android.content.Context
|
|
|
import android.view.Window
|
|
|
+import com.adealink.frame.util.DisplayUtil.getDisplayMetrics
|
|
|
import com.adealink.frame.util.DisplayUtil.getNavMenuHeight
|
|
|
import com.adealink.frame.util.DisplayUtil.getStatusBarHeight
|
|
|
|
|
|
@@ -10,14 +11,38 @@ fun Activity?.statusBarHeight(): Int {
|
|
|
return this?.window.statusBarHeight()
|
|
|
}
|
|
|
|
|
|
+fun Activity?.statusBarHeightDp(): Int {
|
|
|
+ val scale = getDisplayMetrics().density
|
|
|
+ return (this?.window.statusBarHeight() / scale).toInt()
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
fun Window?.statusBarHeight(): Int {
|
|
|
return this?.let {
|
|
|
getStatusBarHeight(it)
|
|
|
} ?: 0
|
|
|
}
|
|
|
|
|
|
+fun Window?.statusBarHeightDp(): Int {
|
|
|
+ val heightPx = this?.let {
|
|
|
+ getStatusBarHeight(it)
|
|
|
+ } ?: 0
|
|
|
+ val scale = getDisplayMetrics().density
|
|
|
+ return (heightPx / scale).toInt()
|
|
|
+}
|
|
|
+
|
|
|
fun Context?.naviBarHeight(): Int {
|
|
|
- return this?.let {
|
|
|
+ val heightPx = this?.let {
|
|
|
+ getNavMenuHeight(it)
|
|
|
+ } ?: 0
|
|
|
+ val scale = getDisplayMetrics().density
|
|
|
+ return (heightPx / scale).toInt()
|
|
|
+}
|
|
|
+
|
|
|
+fun Context?.naviBarHeightDp(): Int {
|
|
|
+ val heightPx = this?.let {
|
|
|
getNavMenuHeight(it)
|
|
|
} ?: 0
|
|
|
+ val scale = getDisplayMetrics().density
|
|
|
+ return (heightPx / scale).toInt()
|
|
|
}
|