check if user has internet connection in kotlin

Java
InternetCheck(object : InternetCheck.Consumer {
  override fun accept(internet: Boolean?) {
    Log.d("test", "asdasdas")
    }
})
Source

Also in Java: