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

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

    webαʔϏε͕͢Ͱʹ͋Δ৔߹ - طଘސ٬ͷधཁͷݕূͱαʔϏε༏Ґੑͱͯ͠ͷҐஔ෇͚
 ্هͷཧ༝͔ΒͳΔૣͰඞཁɺ݁Ռ Ϣʔβʔൺ͸ iOS:Android Ͱ 4:1͘Β͍ Ͱ΋ߋ৽ස౓͸ಉ͘͡Β͍
  4. 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೥΄Ͳӡ༻ͯͨ݁͠Ռ
  5. 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
  6. 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 ࣗ༝౓͕ߴ͍Ώ͑ʹ • ϑΝΠϧ໊͕த਎Λද͞ͳ͍ • είʔϓΛ෼͚ʹ͍͘ • ࢓༷͕Ṗϝιουͭ͘Γ͕ͪ Ξϯν
  7. //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 ʢղʣ
  8. είʔϓؔ਺ʢΞϯνύλʔϯʣ check1?.let{ c1 -> check2?.let{ c2 -> check3.let{ c3 ->

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

    check3 != null){ // ... } val ok:OK? = check1?.let{ it.toOK() } ࢖͍Ͳ͜Λ෼͚Δ • جຊతʹifจͰnull൑ఆ • ͦΕҎ֎ͷcast΍஋Λࢀরͨ͠Ωϟετͷ࣌ʹ࢖͏ ͜͏͠Α͏
  10. 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
  11. EnumʢΞϯνύλʔϯʣ enum class TestType{ case1, case2, case3 } val type

    = TestType.case1 when (type){ TestType.case1 -> {} } SwiftͰ࣮૷͞ΕͨΑ͏ͳwhenͰʮશྻڍ͞Εͯͳ͍ʯ͔ͭʮelse͕ͳ͍ʯ৔߹Ͱ΋ Τϥʔ͕ग़ͳ͍ͷͰɺྻڍ࿙ΕΛੜΉ ྻڍ࿙ΕͰCompile Errorग़ͯ΄͍͠ • Πϕϯτϩάͷ࣮૷࿙Εͱ͔๷͙ͷʹ
 iOSͰ͔ͭͬͯͨΓͨ͠ Ξϯν
  12. 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ग़Δͧʂ ͜͏͠Α͏