Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Anko試食会

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.
Avatar for watanave watanave
February 05, 2018

 Anko試食会

DroidKaigi 2018

Avatar for watanave

watanave

February 05, 2018
Tweet

More Decks by watanave

Other Decks in Programming

Transcript

  1. 9.- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/ apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"

    android:orientation="vertical" tools:context="jp.watanave.ankosamples.XMLActivity"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="SAY hello"/> </LinearLayout>
  2. <LinearLayout xmlns:android="http://schemas.android.com/ apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="jp.watanave.ankosamples.XMLActivity"> <EditText android:layout_width="match_parent"

    android:layout_height="wrap_content" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="SAY hello"/> </LinearLayout> verticalLayout { editText() button("Say Hello") } 9.- "OLP%4-
  3. 9.- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:background="@android:color/darker_gray" tools:context="jp.watanave.ankosamples.XMLActivity"> <TextView

    android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/red" android:textColor="#FF0000"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/white" android:textColor="#FFFFFF"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/yellow" android:textColor="#FFFB00"/> </LinearLayout>
  4. "OLP%4- linearLayout { backgroundColor = Color.DKGRAY textView { text =

    "͔͋" textColor = Color.RED } textView { text = "͠Ζ" textColor = Color.WHITE } textView { text = "͖͍Ζ" textColor = Color.YELLOW } }
  5. "OLP%4- linearLayout { backgroundColor = Color.DKGRAY textView { text =

    "͔͋" textColor = Color.RED } textView { text = "͠Ζ" textColor = Color.WHITE } textView { text = "͖͍Ζ" textColor = Color.YELLOW } } linearLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋" textColor = Color.RED } textView { text = "͠Ζ" textColor = Color.WHITE } textView { text = "͖͍Ζ" textColor = Color.YELLOW } } linearLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋" textColor = Color.RED }
  6. "OLP%4- linearLayout { backgroundColor = Color.DKGRAY textView { text =

    "͔͋" textColor = Color.RED } textView { text = "͠Ζ" textColor = Color.WHITE } textView { text = "͖͍Ζ" textColor = Color.YELLOW } } ϒϨʔεͷதͰϓϩύςΟηοτ linearLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋" textColor = Color.RED } textView { text = "͠Ζ" textColor = Color.WHITE } textView { text = "͖͍Ζ" textColor = Color.YELLOW } } textView { text = “͔͋" textColor = Color.RED }
  7. "OLP%4- linearLayout { backgroundColor = Color.DKGRAY textView { text =

    "͔͋" textColor = Color.RED } textView { text = "͠Ζ" textColor = Color.WHITE } textView { text = "͖͍Ζ" textColor = Color.YELLOW } }
  8. "OLP%4- linearLayout { backgroundColor = Color.DKGRAY textView { text =

    "͔͋" textColor = Color.RED }.lparams { margin = dip(10) } textView { text = "͠Ζ" textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = "͖͍Ζ" textColor = Color.YELLOW }.lparams { margin = dip(10) } }
  9. "OLP%4- linearLayout { backgroundColor = Color.DKGRAY textView { text =

    "͔͋" textColor = Color.RED }.lparams { margin = dip(10) } textView { text = "͠Ζ" textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = "͖͍Ζ" textColor = Color.YELLOW }.lparams { margin = dip(10) } } linearLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋" textColor = Color.RED }.lparams { margin = dip(10) } textView { text = "͠Ζ" textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = "͖͍Ζ" textColor = Color.YELLOW }.lparams { margin = dip(10) } } textView { text = "͔͋" textColor = Color.RED }.lparams { margin = dip(10) }
  10. "OLP$PNQPOFOU class MyActivity : AppCompatActivity() { // ུ } class

    MyActivityUI : AnkoComponent<MyActivity> { } class MyActivity : AppCompatActivity() { // ུ } class MyActivityUI : AnkoComponent<MyActivity> { }
  11. "OLP$PNQPOFOU class MyActivity : AppCompatActivity() { // ུ } class

    MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSLॻ͘ } } class MyActivity : AppCompatActivity() { // ུ } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSLॻ͘ } }
  12. "OLP$PNQPOFOU class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?)

    { super.onCreate(savedInstanceState) } } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSLॻ͘ } } class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSLॻ͘ } }
  13. "OLP$PNQPOFOU class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?)

    { super.onCreate(savedInstanceState) MyActivityUI().setContentView(this) } } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSLॻ͘ } } class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) MyActivityUI().setContentView(this) } } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSLॻ͘ } }
  14. "OLPղମγϣʔ linearLayout { backgroundColor = Color.DKGRAY textView { text =

    "͔͋" textColor = Color.RED }.lparams { margin = dip(10) } textView { text = "͠Ζ" textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = "͖͍Ζ" textColor = Color.YELLOW }.lparams { margin = dip(10) } } linearLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋" textColor = Color.RED }.lparams { margin = dip(10) } textView { text = "͠Ζ" textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = "͖͍Ζ" textColor = Color.YELLOW }.lparams { margin = dip(10) } }
  15. MJOFBS-BZPVUΛίʔϧ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) { ui.linearLayout ({ // do something }) }
  16. %4-ͬΆ͘ίʔϧ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) { ui.linearLayout ({ // do something }) } fun createView(ui: AnkoContext) { ui.linearLayout ({ // do something }) }
  17. %4-ͬΆ͘ίʔϧ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) { ui.linearLayout { // do something } } ɹɹ
  18. XJUI inline fun <T, R> with(receiver: T, block: T.() ->

    R): R (source) rIUUQTLPUMJOMBOHPSHBQJMBUFTUKWNTUEMJCLPUMJOXJUIIUNM l༩͑ΒΕͨϨγʔόΛϨγʔόͱͯ͠ࢦఆͨ͠ϑΝϯ ΫγϣϯϒϩοΫΛݺͼग़͠ɺͦͷ݁ՌΛฦ͠·͢ɻz
  19. %4-ͬΆ͘ίʔϧ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) { ui.linearLayout { // do something } }
  20. XJUI࢖ͬͯΈΔ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) { with(ui, { this.linearLayout { // do something } }) } ui { this.linearLayout { // do something } }
  21. ୯Ұࣜؔ਺ͩͬͨ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) { with(ui, { this.linearLayout { // do something } }) } with(ui, { this.linearLayout { // do something } })
  22. ୯Ұࣜؔ਺ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui, { this.linearLayout { // do something } })
  23. ΋ͬͱ%4-ͬΆ͘ίʔϧ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui, { this.linearLayout { // do something } })
  24. ΋ͬͱ%4-ͬΆ͘ίʔϧ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui) { this.linearLayout { // do something } }
  25. ΋ͬͱ΋ͬͱ%4-ͬΆ͘ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui) { linearLayout { // do something } }
  26. ϓϩύςΟ͸Ͳ͏΍ͬͯʁ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui) { linearLayout { } } backgroundColor = Color.DKGRAY
  27. ͜Ε͸ҧ͏ʁ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui) { linearLayout { linearLayout -> linearLayout.backgroundColor = Color.DKGRAY } }
  28. ͜Ε΋ҧ͏ʁ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui) { linearLayout { linearLayout -> with(linearLayout) { this.backgroundColor = Color.DKGRAY } } }
  29. JOJUͷUIJTΛ-JOFBS-BZPVUʹ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui) { linearLayout { // ͜ͷείʔϓͷthisΛLinearLayoutʹ͍ͨ͠ʂ } }
  30. ϓϩύςΟ͸Ͳ͏΍ͬͯʁ class AnkoContext(val ctx: Context) { fun linearLayout(init: ()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui) { linearLayout { } }
  31. ϓϩύςΟ͸Ͳ͏΍ͬͯʁ class AnkoContext(val ctx: Context) { fun linearLayout(init: LinearLayout.()->Unit) :

    LinearLayout { return LinearLayout(ctx) } } fun createView(ui: AnkoContext) = with(ui) { linearLayout { } }
  32. ϓϩύςΟ͸Ͳ͏΍ͬͯʁ class AnkoContext(val ctx: Context) { fun linearLayout(init: LinearLayout.()->Unit) :

    LinearLayout { val linearLayout = LinearLayout(ctx) linearLayout.init() return linearLayout } } fun createView(ui: AnkoContext) = with(ui) { linearLayout { backgroundColor = Color.DKGRAY } } this.
  33. 5FYU7JFXΛ഑ஔ͍ͨ͠ class AnkoContext(val ctx: Context) { fun linearLayout(init: LinearLayout.()->Unit) :

    LinearLayout { val linearLayout = LinearLayout(ctx) linearLayout.init() return linearLayout } } fun createView(ui: AnkoContext) = with(ui) { linearLayout { backgroundColor = Color.DKGRAY } } textView { text = "͋Μ͜" }
  34. 5FYU7JFX΋࣮૷ͯ͠ΈΔ fun linearLayout(init: LinearLayout.()->Unit) : LinearLayout { val linearLayout =

    LinearLayout(ctx) linearLayout.init() return linearLayout } fun textView(init: TextView.()->Unit) : TextView { val textView = TextView(ctx) textView.init() return textView }
  35. 5FYU7JFX΋࣮૷ͯ͠ΈΔ class AnkoContext(val ctx: Context) { fun linearLayout(init: LinearLayout.()->Unit) :

    LinearLayout { val linearLayout = LinearLayout(ctx) linearLayout.init() return linearLayout } } fun ViewGroup.textView(init: TextView.()->Unit) : TextView { val textView = TextView(this.context) textView.init() return textView }
  36. "EE7JFXͯ͠ͳ͔ͬͨ class AnkoContext(val ctx: Context) { fun linearLayout(init: LinearLayout.()->Unit) :

    LinearLayout { val linearLayout = LinearLayout(ctx) linearLayout.init() (ctx as Activity).setContentView(linearLayout) return linearLayout } } fun ViewGroup.textView(init: TextView.()->Unit) : TextView { val textView = TextView(this.context) textView.init() this.addView(textView) return textView }
  37. ೖΕࢠߏ଄Ͱ͖ͨ fun createView(ui: AnkoContext) = with(ui) { return linearLayout {

    backgroundColor = Color.DKGRAY textView { text = “͋Μ͜" } } }
  38. MQBSBNTΛͲ͏͢Δ͔ fun createView(ui: AnkoContext) = with(ui) { linearLayout { backgroundColor

    = Color.DKGRAY textView { text = “͋Μ͜" }.lparams { } } }
  39. 5FYU7JFXΛ֦ு fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams

    = LinearLayout.LayoutParams(width, height) layoutParams.init() this.layoutParams = layoutParams return this } fun createView(ui: AnkoContext) = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = “͋Μ͜" }.lparams { } } }
  40. ܕҧ͏໰୊ fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams

    = LinearLayout.LayoutParams(width, height) layoutParams.init() this.layoutParams = layoutParams return this } fun createView(ui: AnkoContext) = with(ui) { relativeLayout { backgroundColor = Color.DKGRAY textView { text = “͋Μ͜" }.lparams { } } } #
  41. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() ->

    Unit): TextView { val layoutParams = LinearLayout.LayoutParams() layoutParams.init() this.layoutParams = layoutParams return this } } @ΫϥεΛ࡞Δ
  42. @ΫϥεΛฦ͢ class AnkoContext(val ctx: Context) { fun linearLayout(init: LinearLayout.()->Unit) :

    _LinearLayout { val linearLayout = _LinearLayout(ctx) linearLayout.init() return linearLayout } }
  43. class _FrameLayout(context: Context) : FrameLayout(context) { fun TextView.lparams(init: FrameLayout.LayoutParams.() ->

    Unit): TextView { class _RelativeLayout(context: Context) : RelativeLayout(context) { fun TextView.lparams(init: RelativeLayout.LayoutParams.() -> Unit): TextView { class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { class _FrameLayout(context: Context) : FrameLayout(context) { fun TextView.lparams(init: FrameLayout.LayoutParams.() -> Unit): TextView { class _RelativeLayout(context: Context) : RelativeLayout(context) { fun TextView.lparams(init: RelativeLayout.LayoutParams.() -> Unit): TextView {
  44. linearLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋"

    textColor = Color.RED }.lparams { weight = 1.0f } // ུ } linearLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋" textColor = Color.RED }.lparams { weight = 1.0f } // ུ }
  45. relativeLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋"

    textColor = Color.RED }.lparams { centerInParent() } // ུ } relativeLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋" textColor = Color.RED }.lparams { centerInParent() } // ུ }
  46. "OLP%4- linearLayout { backgroundColor = Color.DKGRAY textView { text =

    "͔͋" textColor = Color.RED }.lparams { margin = dip(10) } textView { text = "͠Ζ" textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = "͖͍Ζ" textColor = Color.YELLOW }.lparams { margin = dip(10) } } linearLayout { backgroundColor = Color.DKGRAY textView { text = "͔͋" textColor = Color.RED }.lparams { margin = dip(10) } textView { text = "͠Ζ" textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = "͖͍Ζ" textColor = Color.YELLOW }.lparams { margin = dip(10) } }
  47. ܕ҆શ class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>):

    View = with(ui) { verticalLayout { val textView = textView("0") val button = button("OK") } } }
  48. ܕ҆શ class MyActivityUI : AnkoComponent<MyActivity> { var textView: TextView? var

    button: Button? override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { textView = textView("0") button = button("OK") } } }
  49. ܕ҆શ class MyActivityUI : AnkoComponent<MyActivity> { lateinit var textView: TextView

    private set lateinit var button: Button private set override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { textView = textView("0") button = button("OK") } } }
  50. ಈతͳϨΠΞ΢τ class MyActivityUI(private val theme: Int, private val buttonTheme: Int)

    : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { owner.setTheme(theme) verticalLayout { textView("0") button(“OK") themedButton("Cancel", buttonTheme) } } }
  51. ಈతͳϨΠΞ΢τ class MyActivityUI(private val theme: Int, private val buttonTheme: Int)

    : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { owner.setTheme(theme) verticalLayout { textView("0") button(“OK") themedButton("Cancel", buttonTheme) } } }
  52. ಈతͳϨΠΞ΢τ class MyActivityUI(private val theme: Int, private val buttonTheme: Int)

    : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { owner.setTheme(theme) verticalLayout { textView("0") button(“OK") themedButton("Cancel", buttonTheme) } } }
  53. ಈతͳϨΠΞ΢τ class MyActivityUI(private val theme: Int, private val buttonTheme: Int)

    : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { owner.setTheme(theme) verticalLayout { textView("0") button(“OK") themedButton("Cancel", buttonTheme) } } }
  54. ϨΠΞ΢τͷ࠶ར༻ interface SampleUI<in T> : AnkoComponent<T> { override fun createView(ui:

    AnkoContext<T>): View = with(ui) { relativeLayout { imageView(R.drawable.zebra) { scaleType = ImageView.ScaleType.FIT_XY }.lparams(width = matchParent, height = matchParent) createInnerView().lparams { centerInParent() } } } fun _RelativeLayout.createInnerView() : View }
  55. ϨΠΞ΢τͷ࠶ར༻ interface SampleUI<in T> : AnkoComponent<T> { override fun createView(ui:

    AnkoContext<T>): View = with(ui) { relativeLayout { imageView(R.drawable.zebra) { scaleType = ImageView.ScaleType.FIT_XY }.lparams(width = matchParent, height = matchParent) createInnerView().lparams { centerInParent() } } } fun _RelativeLayout.createInnerView() : View }
  56. ϨΠΞ΢τͷ࠶ར༻ interface SampleUI<in T> : AnkoComponent<T> { override fun createView(ui:

    AnkoContext<T>): View = with(ui) { relativeLayout { imageView(R.drawable.zebra) { scaleType = ImageView.ScaleType.FIT_XY }.lparams(width = matchParent, height = matchParent) createInnerView().lparams { centerInParent() } } } fun _RelativeLayout.createInnerView() : View }
  57. ϨΠΞ΢τͷ࠶ར༻ class Sample1UI: SampleUI<Context> { override fun _RelativeLayout.createInnerView() : View

    = with(this) { button("Button") } } class Sample2UI: SampleUI<Context> { override fun _RelativeLayout.createInnerView() : View = with(this) { textView("text") } } class Sample3UI: SampleUI<Context> { override fun _RelativeLayout.createInnerView() : View = with(this) { progressBar() } }
  58. ϨΠΞ΢τͷ࠶ར༻ class Sample1UI: SampleUI<Context> { override fun _RelativeLayout.createInnerView() : View

    = with(this) { button("Button") } } class Sample2UI: SampleUI<Context> { override fun _RelativeLayout.createInnerView() : View = with(this) { textView("text") } } class Sample3UI: SampleUI<Context> { override fun _RelativeLayout.createInnerView() : View = with(this) { progressBar() } }
  59. ϨΠΞ΢τͷ࠶ར༻ fun ViewManager.hourlyWeatherView() = customView(theme = 0) {} inline fun

    ViewManager.hourlyWeatherView(init: HourlyWeatherView.()->Unit) : HourlyWeatherView { return ankoView({ HourlyWeatherView(it) }, theme = 0, init = init) } %4-Ͱ࢖͑ΔΑ͏ʹ
  60. ϨΠΞ΢τͷ࠶ར༻ class WeatherActivityUI: AnkoComponent<WeatherActivity> { var hourlyWeatherViews = arrayListOf<HourlyWeatherView>() override

    fun createView(ui: AnkoContext<WeatherActivity>): View = with(ui) { linearLayout { hourlyWeatherView().let { hourlyWeatherViews(it) } hourlyWeatherView().let { hourlyWeatherViews(it) } hourlyWeatherView().let { hourlyWeatherViews(it) } hourlyWeatherView().let { hourlyWeatherViews(it) } hourlyWeatherView().let { hourlyWeatherViews(it) } } } }
  61. ఆ਺Λ༻ҙ class MyActivityUI : AnkoComponent<MyActivity> { private object Ids {

    val editText = 1 val button = 2 } override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = Ids.editText } button("OK") { id = Ids.button } } } }
  62. ఆ਺Λ༻ҙ class MyActivityUI : AnkoComponent<MyActivity> { private object Ids {

    val editText = 1 val button = 2 } override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = Ids.editText } button("OK") { id = Ids.button } } } }
  63. 7JFXHFOFSBUF7JFX*E class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>):

    View = with(ui) { verticalLayout { editText { id = View.generateViewId() } button("OK") { id = View.generateViewId() } } } }
  64. 7JFXHFOFSBUF7JFX*E class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>):

    View = with(ui) { verticalLayout { editText { id = View.generateViewId() } button("OK") { id = View.generateViewId() } } } }
  65. ίʔυͷߦ൪߸ inline fun generateViewId(): Int = Throwable().stackTrace.first().lineNumber class MyActivityUI :

    AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = generateViewId() } button("OK") { id = generateViewId() } } } } -renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable
  66. ίʔυͷߦ൪߸ inline fun generateViewId(): Int = Throwable().stackTrace.first().lineNumber class MyActivityUI :

    AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = generateViewId() } button("OK") { id = generateViewId() } } } } -renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable
  67. ίʔυͷߦ൪߸ inline fun generateViewId(): Int = Throwable().stackTrace.first().lineNumber class MyActivityUI :

    AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = generateViewId() } button("OK") { id = generateViewId() } } } } -renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable