moving some activity extensions to context
This commit is contained in:
parent
9319633c85
commit
c547cb3890
3 changed files with 20 additions and 17 deletions
|
@ -83,7 +83,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_medium)
|
||||
|
||||
top_shadow.layoutParams.height = getStatusBarHeight() + getActionBarHeight()
|
||||
top_shadow.layoutParams.height = statusBarHeight + actionBarHeight
|
||||
if (isOreoPlus()) {
|
||||
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||
|
|
|
@ -278,19 +278,3 @@ fun BaseSimpleActivity.showRecycleBinEmptyingDialog(callback: () -> Unit) {
|
|||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
fun BaseSimpleActivity.getStatusBarHeight(): Int {
|
||||
var statusBarHeight = 0
|
||||
val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
|
||||
if (resourceId > 0) {
|
||||
statusBarHeight = resources.getDimensionPixelSize(resourceId)
|
||||
}
|
||||
return statusBarHeight
|
||||
}
|
||||
|
||||
fun BaseSimpleActivity.getActionBarHeight(): Int {
|
||||
val styledAttributes = theme.obtainStyledAttributes(intArrayOf(android.R.attr.actionBarSize))
|
||||
val actionBarHeight = styledAttributes.getDimension(0, 0f)
|
||||
styledAttributes.recycle()
|
||||
return actionBarHeight.toInt()
|
||||
}
|
||||
|
|
|
@ -49,6 +49,25 @@ internal val Context.navigationBarSize: Point
|
|||
else -> Point()
|
||||
}
|
||||
|
||||
internal val Context.statusBarHeight: Int
|
||||
get() {
|
||||
var statusBarHeight = 0
|
||||
val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
|
||||
if (resourceId > 0) {
|
||||
statusBarHeight = resources.getDimensionPixelSize(resourceId)
|
||||
}
|
||||
return statusBarHeight
|
||||
}
|
||||
|
||||
internal val Context.actionBarHeight: Int
|
||||
get() {
|
||||
val styledAttributes = theme.obtainStyledAttributes(intArrayOf(android.R.attr.actionBarSize))
|
||||
val actionBarHeight = styledAttributes.getDimension(0, 0f)
|
||||
styledAttributes.recycle()
|
||||
return actionBarHeight.toInt()
|
||||
}
|
||||
|
||||
|
||||
val Context.usableScreenSize: Point
|
||||
get() {
|
||||
val size = Point()
|
||||
|
|
Loading…
Reference in a new issue