Last active
December 6, 2017 22:53
-
-
Save sliskiCode/565131f5da03228b4f9c10f908d15b73 to your computer and use it in GitHub Desktop.
6 magic sugars that can make your Kotlin codebase happier #16
This file contains hidden or 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
class MediaItemRenderer : Renderer { | |
override fun render(view: View, item: Item) = with(view) { | |
if (item !is MediaItem) { | |
throw AssertionError("Item is not an instance of MediaItem") | |
} | |
showMedia(item.media) | |
reset() | |
} | |
} | |
class IconItemRenderer : Renderer { | |
override fun render(view: View, item: Item) = with(view) { | |
if (item !is IconItem) { | |
throw AssertionError("Item is not an instance of IconItem") | |
} | |
showIcon(item.icon) | |
reset() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment