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

bonfire android #2

bonfire android #2

Ken Jumbo Haneda

November 06, 2017
Tweet

More Decks by Ken Jumbo Haneda

Other Decks in Programming

Transcript

  1. ͋ΕɺࠓͬͯiOSΑΓAndroidΞϓϦͷ΄͏͕ ࡞ͬͨ΄͏͕Α͘ͳ͍ʁ #POpSF"OESPJE

  2. None
  3. δϟϯϘ@jumboOrNot Kentaro Haneda Mobile Engineer@RareJob Tech Lead@LandSkip
 Swift/kotlin/golang/WebRTC

  4. ͋ΕɺࠓͬͯiOSΑΓAndroidΞϓϦͷ΄͏͕ ࡞ͬͨ΄͏͕Α͘ͳ͍ʁ #POpSF"OESPJE

  5. ࠓ೔ͷ͓࿩ ·ͩkotlinʢAndroidʣΛ΍ͬͯͳ͍ਓ޲͚ʹ ʮͦΖͦΖkotlin࢝ΊΑ͏Αʯͬͯ࿩Λ͍ͨ͠ ↓ ʮͦΕ͸ͳͥʯ ʮͲΜͳαʔϏεɾϑΣʔζͰͦ͏ͳͷ͔ʯ ↓ ʮJavaΑΓ͜Μ͚͍͍ͩͧʂʯ ʮ࡞ΔͳΒ͜ͷลؾΛ͚ͭͯ͜ʯ

  6. ಋೖ “ͳͥAndroidΞϓϦΛ࡞Δͷʁ”

  7. 2017೥಄ͷσόΠεγΣΞ Ҿ༻: http://www.idc.com/promo/smartphone-market-share/os http://www.ai-bibo.net/entry/2017/02/10/113350, https://www.kantarworldpanel.com/global/smartphone-os-market-share/ 14.7 49.5 16.4 42 4.3

    85 49 83.5 56.4 94.4 0.2 0.95 1.42 1.61 1.3 0 20 40 60 80 100 120      ios android 
  8. 2016೥ͷϚʔέοτऩӹϥϯΩϯά ▪ iOS 1Ґ China 2Ґ Unites States 3Ґ Japan

    Android
 1Ґ Japan 2Ґ United States 3Ґ South Korea Ҿ༻: https://www.appannie.com/jp/insights/market-data/app-annie-2016-retrospective/ ೔ຊ͸DL਺ͱऩӹֹ͕͍ۚۙਪҠͰ ಈ͍͍ͯΔɻ ୯ՁͰݟΔͱؖࠃͱ͔͸DL਺͕গͳׂ͍ʹ ऩӹֹ͕ଟ͍ͷͰ୯Ձ͕େ͖͍ɻ ଞࠃϦʔδϣϯ΁ͷల։Λ͍ͯ͠Δ ΞϓϦʹؔ܎͍ͯ͠Δਓ͸ͥͻAppAnnieͷ 2016೥ͷϨϙʔτΛݟ͍ͯͩ͘͞ɺ ௒໘ന͍Ͱ͢
  9. ͱ͸͍͑ ݱ࣮໰୊ͱͯ͠େମͷ৽نαʔϏεͷλʔήοτʹͳΔ ϘϦϡʔϜκʔϯʹ͸iOSϢʔβʔ͕ଟ͍ → iOS͔Β࢝ΊΔαʔϏε͸ඇৗʹଟ͍

  10. Ͱ͸ͦΜͳதɺͲΜͳαʔϏε͕΍Δ΂͖ʁ • ๏ਓ޲͚ʹରԠ͢Δ৔߹ - ๏ਓ୺຤΍҆ՁͳλϒϨοτͰͷల։͕ݟࠐ·ΕΔͨΊ
 • ւ֎΁ͷϦϦʔε͕ܾ·͍ͬͯΔɺείʔϓʹ͋Δ৔߹ - ଟ͘ͷࠃ͸AndroidγΣΞ͕େ͖͍ͨΊ
 •

    webαʔϏε͕͢Ͱʹ͋Δ৔߹ - طଘސ٬ͷधཁͷݕূͱαʔϏε༏Ґੑͱͯ͠ͷҐஔ෇͚
 σόΠε͕૿͑Δ͜ͱ͸୯७ʹίετͳͷͰɺλΠϛϯάͱ Ϧιʔε͸ࣄۀαΠυͰ૬ஊͯ͠΍Γ·͠ΐ͏
  11. ྫʣฐࣾ • ๏ਓ޲͚ʹରԠ͢Δ৔߹ - ๏ਓ୺຤΍҆ՁͳλϒϨοτͰͷల։͕ݟࠐ·ΕΔͨΊ
 • ւ֎΁ͷϦϦʔε͕ܾ·͍ͬͯΔɺείʔϓʹ͋Δ৔߹ - ଟ͘ͷւ֎Ϧʔδϣϯ͸AndroidγΣΞ͕େ͖͍ͨΊ
 •

    webαʔϏε͕͢Ͱʹ͋Δ৔߹ - طଘސ٬ͷधཁͷݕূͱαʔϏε༏Ґੑͱͯ͠ͷҐஔ෇͚
 ্هͷཧ༝͔ΒͳΔૣͰඞཁɺ݁Ռ Ϣʔβʔൺ͸ iOS:Android Ͱ 4:1͘Β͍ Ͱ΋ߋ৽ස౓͸ಉ͘͡Β͍
  12. ϨΞδϣϒӳձ࿩ΞϓϦ Ͱ͖͕͋Γ͕ͪ͜Β

  13. 3BSF+PCΞϓϦ J04 "OESPJE ։ൃݴޠ 4XJGU LPUMJO ։ൃ؀ڥ 9DPEF "OESPJE4UVEJP ΞʔΩςΫνϟ

    3Y4XJGU .77. 3Y+BWB .77. ओͳϥΠϒϥϦ 3Y4XJGU "1*,JU  )JNPUPLJ 3FBMN 3Y+BWB 3FUSpU 
 0L)551 3YCJOE Ξοϓσʔτස౓ গ ଟ ໰͍߹Θͤ݅਺ ଟ গ Ϋϥογϡ গ ଟ Ϣʔβʔൺ཰   ͦͯ͠1೥΄Ͳӡ༻ͯͨ݁͠Ռ
  14. ϦϦʔεαΠΫϧ ɾΫϦΤΠςΟϒվળ
 εΫγϣɺνϡʔτϦΞϧɺಈըɺϔομʔը૾ͳͲ͸GooglePlayͷ ABςετͷػೳͰݕূ͔ͯ͠ΒiOSʹ൓ө͢Δ ɾ΍ͬͨ΄͏͕͍͍͚Ͳɺͪΐͬͱࣗ৴ͳ͍΋ͷ ·ͣAndroidͰϦϦʔεͯ͠ɺظؒΛઃ͚ͯݕূͯ͠iOSͰϦϦʔε
 ͳ͘͢΋ͷ΋͋Δ ɾϏδωεཁ݅ͰϚετͳ΋ͷ Android͔Βઌʹग़͚͢ͲɺͦΕͰAPI΍࢓্༷໰୊ͳ͚Ε͹ iOS͙͢ϦϦʔε

  15. ʮ΍͍͖ͬͯʯΛߟ͑Δ “͡Ό͋Ͳ͏࡞Δͷ͔ɾ࡞ΕΔͷ͔”

  16. kotlin͸਺ଟͷαΠίʔʹܙ·Ε͍ͯΔ ɾExtension ɾScope Function(let/apply/with/run) ɾEnum ͦͷଞॾʑ

  17. kotlin͸਺ଟͷαΠίʔʹܙ·Ε͍ͯΔ ɾExtension ɾScope Function(let/apply/with/run) ɾEnum ͜ΕΒͷศརػೳ΋ͪΌΜͱ࢖͏ɺ
 ϝϦοτΛ೺Ѳͯ͠ਐΊͳ͍ͱ΋͍ͬͨͳ͍ʂ iOSΤϯδχΞ͕͢Ͱʹ౿ΜͰ͖ͨ
 Ξϯνύλʔϯ/ྫΛݩʹ࿩͢

  18. Extension ʢΞϯνύλʔϯʣ fun String.encrypt():String{ //... return encrypted } fun String.toDeviceDate():Date{

    //... return date } fun String.toJPDate():Date{ //... return date } fun String.convertRJTDateString():String{ //… return converted } StringExt.kt
  19. Extension ʢΞϯνύλʔϯʣ fun String.encrypt():String{ //... return encrypted } fun String.toDeviceDate():Date{

    //... return date } fun String.toJPDate():Date{ //... return date } fun String.convertRJTDateString():String{ //… return converted } StringExt.kt ࣗ༝౓͕ߴ͍Ώ͑ʹ • ϑΝΠϧ໊͕த਎Λද͞ͳ͍ • είʔϓΛ෼͚ʹ͍͘ • ࢓༷͕Ṗϝιουͭ͘Γ͕ͪ Ξϯν
  20. //region encrypt/decrypt fun String.encrypt():String{ //... return encrypted } //endregion //region

    convert string fun String.convertSpecificType():String{ //… return converted } //endregion String+Convert.kt String+Date.kt fun String.toJPDate():Date{ //... return date } fun String.convertRJTDateString():String{ //… return converted } ผ͚Δɾςετॻ͘ • ϑΝΠϧ໊Λ{{class}}+{{category}}.kt • regionͰϝιουΛ੔ཧ • ͳΔ΂͘ςετΛॻ͜͏ ͜͏͠Α͏ Extension ʢղʣ
  21. είʔϓؔ਺ʢΞϯνύλʔϯʣ check1?.let{ c1 -> check2?.let{ c2 -> check3.let{ c3 ->

    // ... } } } ifͱletΛࠞಉ͢Δ • ωετ͕ͪ͠ • είʔϓؔ਺ͱ͍͏͔ifจΈ͍ͨʹ࢖ΘΕΔ Ξϯν
  22. είʔϓؔ਺ʢղʣ if (check1 != null && check2 != null &&

    check3 != null){ // ... } val ok:OK? = check1?.let{ it.toOK() } ࢖͍Ͳ͜Λ෼͚Δ • جຊతʹifจͰnull൑ఆ • ͦΕҎ֎ͷcast΍஋Λࢀরͨ͠Ωϟετͷ࣌ʹ࢖͏ ͜͏͠Α͏
  23. Enum // SwiftͱҟͳΔϙΠϯτ1. ෳ਺ͷॳظ஋ͷઃఆͱΞΫηε enum class Student(val firstName:String, val lastName:String,

    val age:Int){ STUDNET1(firstName = "tarou", lastName = "tanaka", age = 10), STUDNET2(firstName = "jirou", lastName = "suzuki", age = 12) } print(Student.STUDNET1.firstName) // tarou print(Student.STUDNET2.firstName) // jirou print(Student.STUDNET1.toString()) // STUDNET1 // SwiftͱҟͳΔϙΠϯτ2. ྻڍܕఆ਺ͷར༻ʹΑΓfilter΍foreach͕࢖͑Δ Student.values().forEach { student -> print(student.firstName) } kotlinʹ͓͚Δenum͸classͰ͋ΔͷͰɺෳ਺ͷॳظ஋Λ࣋ͬͨΓ
 Java४ڌͳͷͰͰ͖Δ͜ͱ͕ଟ͍˕ ࢀߟ: https://dogwood008.github.io/kotlin-web-site-ja/docs/reference/enum-classes.html
  24. EnumʢΞϯνύλʔϯʣ enum class TestType{ case1, case2, case3 } val type

    = TestType.case1 when (type){ TestType.case1 -> {} } SwiftͰ࣮૷͞ΕͨΑ͏ͳwhenͰʮશྻڍ͞Εͯͳ͍ʯ͔ͭʮelse͕ͳ͍ʯ৔߹Ͱ΋ Τϥʔ͕ग़ͳ͍ͷͰɺྻڍ࿙ΕΛੜΉ ྻڍ࿙ΕͰCompile Errorग़ͯ΄͍͠ • Πϕϯτϩάͷ࣮૷࿙Εͱ͔๷͙ͷʹ
 iOSͰ͔ͭͬͯͨΓͨ͠ Ξϯν
  25. Enumʢղʣ fun needCallAllTestCase(type:TestCase){ val res = when (type){ is TestCase.Case1

    -> { } is TestCase.Case2 -> { } is TestCase.Case3 -> { } } } sealed class TestCase { class Case1(val params:Any) : TestCase() class Case2(val params:Any) : TestCase() class Case3(val params:Any) : TestCase() } ࢀߟ: https://medium.com/@da_pacheco/using-kotlins-sealed-class-to-approximate-swift-s-enum-with-associated- data-7e0abac88bbf Sealed Class࢖͏ • ͪΌΜͱCompile Errorग़Δͧʂ ͜͏͠Α͏
  26. ·ͱΊ ແཧ΍Γಋೖ͢Δͷ͸ྑ͘ͳ͍͚Ͳɺ ଟ͘ͷελʔτΞοϓ΍αʔϏε͸AndroidΞϓϦΛ࡞Δ Մೳੑ͕͋Δ͠ɺࠓճͷΑ͏ͳΞϯνύλʔϯʹߦ͖ண͘ͷͰ͸ʁ null҆શͳͲͷઌഐͰ͋ΔiOSΤϯδχΞ͕౿ΜͰདྷͨ஍ཕΛ
 ·ͨ౿·ͳ͍Α͏ʹφϨοδΛऔΓೖΕͯߦ͖·͠ΐ͏ Enum Scope Function Extension

  27. https://pixta-inc.connpass.com/event/70049/