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
interface ComponentInterface { | |
val onNavigationClick: (() -> Unit)? | |
var searchText: String | |
} | |
class Component : ComponentInterface { | |
private val navigable: Navigable = NavigableImpl() |
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
internal interface Navigable { | |
val onNavigationClick: (() -> Unit)? | |
} | |
internal interface Searchable { | |
var searchText: String | |
} |
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
interface Navigable { | |
val onNavigationClick: (() -> Unit)? | |
} | |
interface Searchable { | |
var searchText: String | |
} |
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
public final class MediaItemRenderer { | |
public final void render(@NotNull View view, @NotNull Item item) { | |
if (!(item instanceof MediaItem)) { | |
throw (Throwable)(new IllegalArgumentException("Invalid type, should be " + MediaItem.class.getSimpleName())); | |
} else { | |
MediaItem it = (MediaItem)item; | |
view.show((Function0)(new MediaItemRenderer$render$1$1$1(it))); | |
view.reset(); | |
} | |
} |
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) { | |
withCorrectType<MediaItem>(item) { | |
show { it.media() } | |
reset() | |
} | |
} | |
} |
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
fun <T> withCorrectType(toBeChecked: Item, block: (T) -> Unit) { | |
if (toBeChecked !is T) { | |
throw IllegalArgumentException("Invalid type") | |
} | |
block.invoke(toBeChecked) | |
} |
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() | |
} |
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
abstract class Item | |
class MediaItem : Item() { | |
val media = ... | |
} | |
class IconItem : Item() { | |
val icon = ... | |
} |
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
interface View { | |
fun show() | |
fun hide() | |
fun reset() | |
fun clear() | |
} | |
class Presenter(private val view: View) { |
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
val sugar = "Fructos" | |
with(sugar) { | |
println(toUpperCase()) | |
println(toLowerCase()) | |
println(capitalize()) | |
} |