You are currently viewing Java to Kotlin Question

Java to Kotlin Question

Hey there. I’m just learning Kotlin. Does anyone know how to convert this java code to Kotlin syntax?

youTubePlayerView = YouTubePlayerView(requireContext())
val layout = view.findViewById(R.id.linearlayoutgroup) as LinearLayout
layout.addView(youTubePlayerView)

lifecycle.addObserver(youTubePlayerView)

youTubePlayerView.getYouTubePlayerWhenReady(youTubePlayer -> {

// do stuff with it

})

I can call the function getYouTubePlayerWhenReady pretty well but the parameter in it is the one I’m not sure how to translate to Kotlin. The youtubePlayer is a callback

submitted by /u/wansyazlina
[link] [comments]