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

100 lines or die

mattak
January 15, 2016

100 lines or die

KotlinAndroid勉強会 LT

mattak

January 15, 2016
Tweet

More Decks by mattak

Other Decks in Programming

Transcript

  1. 31# 133# 108# 88# 65# 39# 26# 18# 14# 7#

    5# 4# 4# 1# 0# 0# 0# 1# 0# 0# 0# 0# 0# 0# 0# 0# 1# 0# 20# 40# 60# 80# 100# 120# 140# 0# 10# 20# 30# 40# 50# 60# 70# 80# 90# 100# 110# 120# 130# 140# 150# 160# 170# 180# 190# 200# 210# 220# 230# 240# 250# 260# (16 files / 545 files) 2.9%
  2. 1" 49" 44" 33" 23" 20"20" 17"17" 11" 8" 8"

    10" 2" 3" 4" 3" 4" 5" 5" 0" 2" 0" 1" 0" 2" 0" 1" 1" 2" 1" 0" 0" 1" 0" 1" 1" 0" 0" 0" 0" 0" 0" 0" 1" 0" 0" 0" 0" 0" 0" 0" 1" 0" 10" 20" 30" 40" 50" 60" 0" 20" 40" 60" 80" 100" 120" 140" 160" 180" 200" 220" 240" 260" 280" 300" 320" 340" 360" 380" 400" 420" 440" 460" 480" 500" 520" (67 files / 307 files) 21.8%
  3. "DUJWJUZ $VTUPN 7JFX 'SBHNFOU 7JFX .PEFM .PEFM 4FSWJDF Presentation Layer

    Business Layer 20͘Β͍ 100͘Β͍ 100͘Β͍ 100͘Β͍ 10͘Β͍
  4. <?xml version="1.0" encoding="utf-8"?>
 <me.mattak.sampleapp.CustomView xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical">
 
 <TextView


    android:id="@+id/text"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content" />
 
 </me.mattak.sampleapp.CustomView> CustomViewͰxmlΛ૊Ή (ύʔπ͸খ͘͞খ෼͚)
  5. class CustomView : FrameLayout {
 val textView: TextView by bindView(R.id.text)


    
 constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
 constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {}
 
 override fun onFinishInflate() {
 super.onFinishInflate()
 if (this.isInEditMode) { return }
 
 // model͔Βσʔλऔಘ
 val data = Observable.just("text")
 
 // observable<String>ͷ಺༰͕TextViewʹ൓ө͞ΕΔ
 TextViewModel(this.textView, data).subscribe()
 }
 } CustomView಺ͰσʔλόΠϯυ
  6. // File: ScoreEntity.kt
 data class ScoreEntity(
 val param1: Int,
 val

    param2: Int
 ) αʔόʔͱ௨৴͢Δࡍͷ Entity৘ใ͸ࣗಈੜ੒͞ΕΔ
  7. 
 // File: ScoreEntityExtension.kt
 val ScoreEntity.score: Int
 get() = param1

    * param2 Entityʹ෇ਵ͢Δͪΐͬͱͨ͠ϩδοΫ͸ Extensionͱͯ͠ผϑΝΠϧʹॻ͘