Skip to content

Instantly share code, notes, and snippets.

View RoarGronmo's full-sized avatar
🏠
Works nearly all the time...

Roar Grønmo RoarGronmo

🏠
Works nearly all the time...
  • Grønmo IT / Norva24
  • Stryn, Norway
View GitHub Profile
@kevinhaitsma
kevinhaitsma / MetricsUtil.kt
Created February 27, 2018 07:36
Convert dp to px and px to dp in Kotlin for Android
import android.content.Context
import android.content.res.Resources
import android.util.DisplayMetrics
/**
* Provides utilities for metrics.
*
* Original at:
* @see <a href="https://stackoverflow.com/a/9563438/8877070">stack overflow answer</a>
*
@kibotu
kibotu / GoogleMaps+Extensions.kt
Last active February 11, 2021 17:34
GoogleMap workaround to keep bearing:
/**
* map.animateCamera(CameraUpdateFactory.newLatLngBounds()) will lose ignore current bearing and rotate the camera
*/
fun GoogleMap.animateToBounds(bounds: LatLngBounds, width: Int, height: Int) = animateCamera(boundsToCameraUpdate(bounds, width, height))
/**
* map.moveCamera(CameraUpdateFactory.newLatLngBounds()) will lose ignore current bearing and rotate the camera
*/
fun GoogleMap.moveCameraToBounds(bounds: LatLngBounds, width: Int, height: Int) = moveCamera(boundsToCameraUpdate(bounds, width, height))