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
fun <T> ViewGroup.toAnkoViewHolder(createView: AnkoContext<ViewGroup>.(((T) -> Unit) -> Unit) -> View): AnkoViewHolder = | |
AnkoViewHolder.create(this, createView) | |
class AnkoViewHolder(itemView: View, private val onBind: (Any) -> Unit) : RecyclerView.ViewHolder(itemView) { | |
fun bind(item: Any) = onBind(item) | |
companion object { | |
@Suppress("UNCHECKED_CAST") |
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
import android.app.Activity | |
import android.app.Instrumentation | |
import android.content.Context | |
import android.support.annotation.LayoutRes | |
import android.support.test.InstrumentationRegistry | |
import android.support.test.rule.ActivityTestRule | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup |
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
private val Store<Car>.frontLeftWheel: Wheel | |
get() = getState().wheels.entries.first { it.key == Position.FRONT_LEFT }.value | |
class ChangeWheelFeature : Feature({ | |
lateinit var store: Store<Car> | |
given("the wheel is a 15 inch one") { | |
setUp { store = newStore() } |
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
LinearLayout(this).apply { | |
orientation = LinearLayout.VERTICAL | |
addView(TextView(context).apply { | |
text = "Hello" | |
}) | |
addView(TextView(context).apply { | |
text = "click me" |
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
LinearLayout(this).apply { | |
orientation = LinearLayout.VERTICAL | |
addView(TextView(context).apply { | |
text = "Hello" | |
}) | |
addView(TextView(context).apply { | |
text = "click me" |
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
LinearLayout(this) layout { | |
// ... | |
} | |
infix fun <V : ViewGroup> V.layout(block: Layout<V>.() -> Unit): V = | |
also { Layout(it).run(block) } | |
class Layout<V : ViewGroup>(val layout: V) : ViewManager by layout, ViewParent by layout {} |
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
LinearLayout(this) layout { | |
+TextView(context).apply { | |
text = "Hello world" | |
} | |
} | |
class Layout<V : ViewGroup>(val layout: V) : ViewManager by layout, ViewParent by layout { | |
val context = layout.context |
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
LinearLayout(this) layout { | |
+TextView(context) { | |
text = "Hello world" | |
} | |
} | |
class Layout<V : ViewGroup>(val layout: V) : ViewManager by layout, ViewParent by layout { | |
// ... |
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
LinearLayout(this) layout { | |
+textView { | |
text = "Hello world" | |
} | |
} | |
val Layout<*>.textView: TextView get() = TextView(context) | |
val Layout<*>.button: Button get() = Button(context) |
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
LinearLayout(this) layout { | |
// ... | |
} | |
infix fun <V : ViewGroup> V.layout(block: Layout<V>.() -> Unit): V = | |
also { Layout(it).run(block) } | |
class Layout<V : ViewGroup>(val layout: V) : ViewManager by layout, ViewParent by layout {} |
OlderNewer