Skip to content

Instantly share code, notes, and snippets.

@svinouze
Created November 5, 2020 13:46
Show Gist options
  • Save svinouze/7634b5b4791e74ff88fa32e7a9a964d6 to your computer and use it in GitHub Desktop.
Save svinouze/7634b5b4791e74ff88fa32e7a9a964d6 to your computer and use it in GitHub Desktop.
interface FabulousListener {
fun onClick()
}
class FabulousFragment : Fragment() {
companion object {
fun newInstance() = FabulousFragment()
}
var listener: FabulousListener? = null
override fun onAttach(context: Context) {
super.onAttach(context)
if (context is FabulousListener) {
listener = context
} else {
throw ClassCastException("$context must implement FabulousListener")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment