Created
November 5, 2020 13:46
-
-
Save svinouze/7634b5b4791e74ff88fa32e7a9a964d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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