Skip to content

Instantly share code, notes, and snippets.

@emmaguy
Created March 7, 2016 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emmaguy/8cd13c080062b3f39dfc to your computer and use it in GitHub Desktop.
Save emmaguy/8cd13c080062b3f39dfc to your computer and use it in GitHub Desktop.
import android.os.Build
public fun supportsKitKat(code:() -> Unit){
supportsVersion(code, 19)
}
public fun supportsLollipop(code:() -> Unit){
supportsVersion(code, 21)
}
private fun supportsVersion(code:() -> Unit, sdk: Int){
if (Build.VERSION.SDK_INT >= sdk){
code.invoke()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment