Skip to content

Instantly share code, notes, and snippets.

import android.annotation.SuppressLint
import android.graphics.Rect
import android.os.Build
import android.view.View
import android.view.ViewTreeObserver
import androidx.core.view.updatePaddingRelative
class UnderKeyboardViewElevator(private val decorView: View, private val contentView: View) {
private var initialPaddingBottom: Int = contentView.paddingBottom
@umpteenthdev
umpteenthdev / GeoDecimalToDegreesConverter.kt
Created May 6, 2019 10:22
Convert decimal coordinates to degrees
import kotlin.math.absoluteValue
import kotlin.math.roundToInt
private const val NORTH = "N"
private const val SOUTH = "S"
private const val EAST = "E"
private const val WEST = "W"
fun convertDecimalToDegrees(lat: Double, lng: Double): String = "${convertLat(lat)} ${convertLng(lng)}"
@umpteenthdev
umpteenthdev / MainActivity.kt
Created May 16, 2019 10:00
How to get height of status bar
class MainActivity : ActivityCompat {
private lateinit var bordersListener: ViewTreeObserver.OnGlobalLayoutListener
private var statusBarHeight = 0
override fun onCreate(savedInstanceState: Bundle?) {
val decorView = window.decorView
bordersListener = ViewTreeObserver.OnGlobalLayoutListener {
val r = Rect()