Save 37% off PRO during our Black Friday Sale! »

Guide to app architectureを踏まえた既存アプリの設計改良 / DroidKaigi 2019

C4221ba79492601eb59a9ef5d4f4bbaa?s=47 nakamuuu
February 08, 2019

Guide to app architectureを踏まえた既存アプリの設計改良 / DroidKaigi 2019

DroidKaigi 2019 での発表資料です。 https://droidkaigi.jp/2019/
Room 2 - 2019/02/08 11:20-11:50

【参考資料 / リンク】
・Guide to app architecture | Android Developers
https://developer.android.com/jetpack/docs/guide
・ウィンドウサイズの変更に強い堅牢な画面の構築 | Speaker Deck
https://speakerdeck.com/nakamuuu/droidkaigi-2018
・DroidKaigi/conference-app-2018 | GitHub
https://github.com/DroidKaigi/conference-app-2018
・StateAwareViewModel - nakamuuu | GitHug Gist
https://gist.github.com/nakamuuu/29d7e358735ab867fb145c210d49f8af
・Of Bundles and ViewModels | ProAndroidDev
https://proandroiddev.com/customizing-the-new-viewmodel-cf28b8a7c5fc
・LiveData with SnackBar, Navigation and other events (the SingleLiveEvent case) | Medium
https://medium.com/androiddevelopers/livedata-with-snackbar-navigation-and-other-events-the-singleliveevent-case-ac2622673150
・nakamuuu/jetpack-architecture-playground | GitHub
https://github.com/nakamuuu/jetpack-architecture-playground

C4221ba79492601eb59a9ef5d4f4bbaa?s=128

nakamuuu

February 08, 2019
Tweet

Transcript

  1. Re:valua t ion https://fril.jp/ L ead & Delight User F

    irst Ownership Fail Smart (VJEFUPBQQBSDIJUFDUVSFΛ౿·͑ͨ طଘΞϓϦͷઃܭվྑ
  2. 3BLVNB4FSWJDF%FWFMPQNFOU(SPVQ 3BLVUFO JOD   ࣗݾ঺հ தଜܙଠ !DIJDLNVVV !OBLBNVVV

  3. None
  4.   (VJEFUPBQQBSDIJUFDUVSFΛ౿·͑ͨ طଘΞϓϦͷઃܭվྑ

  5.   ࠓ೔͓࿩͢͠Δ͜ͱ w ࣗ෼ࣗ਎ɺΞϓϦέʔγϣϯͷઃܭʹରͯ͠՝୊Λɹ ײͭͭ͡΋औͬ෇͖ʹ͘͞Λ͍֮͑ͯͨɻ w ઃܭ࿦͸طଘίʔυͷҠߦͷ؍఺ͰޠΒΕʹ͍͘ʁ ʰ"OESPJEͷॳֶऀʱ ʰطʹϨΨγʔͳίʔυΛ๊͑Δ։ൃऀʱ

    λʔήοτ
  6.   ࠓ೔͓࿩͢͠Δ͜ͱ ᶃ طଘΞϓϦͷઃܭվྑʹࢸΔόοΫάϥ΢ϯυ ᶄ (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ ᶅ طଘΞϓϦͷઃܭվྑͷ࣮ྫ ๻ΒͷϓϩμΫτͰͷઃܭվྑͷ࣮ྫΛ௨͠ɺɹɹɹɹ

    ઃܭʹ՝୊Λײ͍ͯ͡ΔਓʹԿ͔ώϯτΛ༩͑ΒΕΕ͹
  7.   طଘΞϓϦͷઃܭվྑʹࢸΔ όοΫάϥ΢ϯυ

  8.   ϓϩμΫτͷόοΫάϥ΢ϯυ ೥ "OESPJE൛ϩʔϯν ೥೥ σβΠϯϦχϡʔΞϧ ೥݄ ৽ʮϥΫϚʯ஀ੜ

  9.   ϓϩμΫτͷόοΫάϥ΢ϯυ w "OESPJEΞϓϦͷઃܭʹର͢Δٞ࿦͸ࠓ΄Ͳਂ͘ͳ͍ w σϑΝΫτͱͳΔٕज़΍πʔϧ΋ఆ·ͬͯͳ͘ɺɹɹ օ͕ख୳ΓͰΞϓϦΛ࡞͍ͬͯΔݹ͖ྑ͖࣌୅ʜʁ ϓϩμΫτͷ஀ੜ͸ʮεϚϗΞϓϦᴈ໌ظʯ ʢ˞౰࣌͸·ͩΤϯδχΞͰͳ͔ͬͨͷͰͨͩͷ఻ฉʣ

  10.   ʁʁʁ "OESPJEΤϯδχΞͷܦݧ஋ ʰࠓ·ͰݟͨதͰҰ൪௕͍"DUJWJUZͷߦ਺ʱ

  11.   ઃܭ໘Ͱͷ՝୊ w ੍໿ͷബ͍ϓϨʔϯͳ.7$ w ࣮૷͕๲Εͨ"DUJWJUZ'SBHNFOU΋ͪΒ΄Βʜ w ੹຿Λڧ͘ҙࣝͰ͖ΔਓͰͳ͚Ε͹ɺ͍͘ΒͰ΋ɹɹ "DUJWJUZ'SBHNFOUʹϏδωεϩδοΫΛॻ͚Δ

    ͜Ε·ͰͷϥΫϚͷઃܭ
  12.   ઃܭ໘Ͱͷ՝୊ ՝୊ᶃ๲ΒΜͩ7JFXͷ࣮૷΁ͷมߋ΍֦ுͷίετ w ෳࡶʹབྷΈ߹͏੍ޚϑϩʔͷதͰ ΤϯόάΛ๷͙ͷ͸೉͍͠ w ྫ͑͹࿈བྷઌɾॅॴͷઃఆը໘͸ "DUJWJUZ͚ͩͰߦ

  13.   ઃܭ໘Ͱͷ՝୊ ՝୊ᶄ7JFX͕࣋ͭϩδοΫͷςετ͕ଘࡏ͠ͳ͍ w Ұ෦ͷϩδοΫΛ੾Γग़ͯ͠ແཧ΍Γݕূ͢Δ͜ͱ͸ Ͱ͖͕ͨɺઃܭϨϕϧͰڧ੍͞ΕΔ͜ͱ͸ͳ͔ͬͨɻ w ςετʹΑΓ୲อͰ͖ͨͰ͋Ζ͏ෆ۩߹΋গͳ͔Βͣ ଘࡏͨ͠ʢྫ͑͹Τϥʔදࣔ౳ͷҟৗܥʜʣ

    w ద੾ʹϏδωεϩδοΫ͕෼཭͍ͯ͠Ε͹๷͛ͨʁ
  14.   ઃܭ໘Ͱͷ՝୊ ՝୊ᶅը໘ճస࣌ͳͲͷ"DUJWJUZ࠶ੜ੒΁ͷऑ͞ w "DUJWJUZͷߏ੒ͷมߋ࠶ੜ੒ʹ ର͢ΔέΞΛޮ཰తʹߦ͑ͳ͍ w ΦϨΦϨͳΞϓϩʔν͕ԣߦ

  15.   ઃܭ໘Ͱͷ՝୊ ՝୊ᶅը໘ճస࣌ͳͲͷ"DUJWJUZ࠶ੜ੒΁ͷऑ͞ ˞ৄࡉ͸ڈ೥ͷ%SPJE,BJHJͷࢿྉࢀর IUUQTTQFBLFSEFDLDPNOBLBNVVVESPJELBJHJ

  16.   ઃܭ໘Ͱͷ՝୊ ҰํͰʜ w ৔౰ͨΓతͳٕज़ͷಋೖ͸ϙϦγʔͱͯ͠ආ͚͖ͯͨ w ϨΨγʔͳϥΠϒϥϦͷґଘ͸গͳ͍ํʁ w ը໘͝ͱʹΑͬͯઃܭ͕ҧ͏ʜͱ͍͏͜ͱ΋ͳ͍

    w 7JFX͔Β෼཭Ͱ͖͍ͯΔϏδωεϩδοΫʹؔͯ͠͸ ςετ΋ॻ͔Ε͍ͯΔ͠ɺઃܭ΋ഁ୼͍ͯ͠ͳ͍
  17.   ઃܭ໘Ͱͷ՝୊ ՝୊ᶃ๲ΒΜͩ7JFXͷ࣮૷΁ͷมߋ΍֦ுͷίετ ՝୊ᶄ7JFX͕࣋ͭϩδοΫͷςετ͕ଘࡏ͠ͳ͍ ՝୊ᶅը໘ճస࣌ͳͲͷ"DUJWJUZ࠶ੜ੒΁ͷऑ͞ ઃܭͷ՝୊͸ݟ͕͑ͨͲ͔͜ΒखΛ͚ͭΕ͹ʜ

  18.   ઃܭ໘Ͱͷ՝୊ (VJEFUPBQQBSDIJUFDUVSFc"OESPJE%FWFMPQFST IUUQTEFWFMPQFSBOESPJEDPNKFUQBDLEPDTHVJEF

  19. (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ  

  20.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ w .PCJMFBQQVTFSFYQFSJFODFT w ϞόΠϧΞϓϦͷ69ʹ͍ͭͯͷલఏ w $PNNPOBSDIJUFDUVSBMQSJODJQMFT w

    ΞʔΩςΫνϟʹؔ͢Δڞ௨ͷݪଇ w 3FDPNNFOEFEBQQBSDIJUFDUVSF w ΞϓϦͷਪ঑ΞʔΩςΫνϟͷৄઆ w #FTUQSBDUJDFT w ίʔυϕʔεͷݎ࿚ੑΛߴΊΔͨΊͷਪ঑ࣄ߲ ଟ෼ϝΠϯ
  21.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ 3FDPNNFOEFEBQQBSDIJUFDUVSF σʔλιʔεͷந৅Խ 7JFX.PEFM ""$  6*༻ͷσʔλ௨஌ͱϞσϧૢ࡞

  22.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ %SPJE,BJHJDPOGFSFODFBQQ IUUQTHJUIVCDPN%SPJE,BJHJDPOGFSFODFBQQ

  23.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ 3FDPNNFOEFEBQQBSDIJUFDUVSFͷ ΞʔΩςΫνϟΛͦͷ··औΓೖΕΔʜʁ ΞʔΩςΫνϟͷݪཧɾݪଇΛཧղ্ͨ͠Ͱ ΑΓϓϩμΫτʹద੾ͳܗΛ୳Γ͍ͨ λʔήοτ͸طଘϓϩμΫτͷϚΠάϨʔτʜ

  24.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ w .PCJMFBQQVTFSFYQFSJFODFT w ϞόΠϧΞϓϦͷ69ʹ͍ͭͯͷલఏ w $PNNPOBSDIJUFDUVSBMQSJODJQMFT w

    ΞʔΩςΫνϟʹؔ͢Δڞ௨ͷݪଇ w 3FDPNNFOEFEBQQBSDIJUFDUVSF w ΞϓϦͷਪ঑ΞʔΩςΫνϟͷৄઆ w #FTUQSBDUJDFT w ίʔυϕʔεͷݎ࿚ੑΛߴΊΔͨΊͷਪ঑ࣄ߲ લఏ ݪଇ ਪ঑ࣄ߲
  25.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ w ඪ४తͳ"OESPJEΞϓϦ͸ɺ"DUJWJUZ'SBHNFOU 4FSWJDFͳͲͷl"QQDPNQPOFOUTz͔Βߏ੒͞ΕΔ w ͦΕΒͷίϯϙʔωϯτ͸ݸผʹॱෆಉͰىಈ͞Εɺɹ Ϣʔβʔ΍04ʹΑͬͯਵ࣌ഁغ͞ΕΔՄೳੑ͕͋Δ w

    σʔλ΍ঢ়ଶΛ"QQDPNQPOFOUTͰอ࣋͢΂͖Ͱͳ͍ લఏ.PCJMFBQQVTFSFYQFSJFODFT
  26.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ w 4FQBSBUJPOPGDPODFSOTؔ৺ͷ෼཭ w "QQDPNQPOFOUTʹ͸6*΍04Λѻ͏ϩδοΫؚ͚ͩΊΔ w %SJWF6*GSPNBNPEFM6*ΛϞσϧͰૢ࡞͢Δ w

    σʔλͷ؅ཧ੹೚Λ࣋ͭج൫Λ"QQ$PNQPOFOUT͔Βɹɹ ෼཭ͤͯ͞ߏங͢ΔʢՄೳͳΒӬଓϞσϧʣ ݪଇ$PNNPOBSDIJUFDUVSBMQSJODJQMFT
  27.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ w "QQ$PNQPOFOUTΛσʔλιʔεͱͯ͠ࢦఆ͠ͳ͍ w ΞϓϦͷ֤छϞδϡʔϧؒͷ੹೚ͷڥքΛ໌֬ʹఆٛ w ֤ϞδϡʔϧΛݸผʹςετͰ͖ΔΑ͏ʹ͢Δ ਪ঑ࣄ߲#FTUQSBDUJDFT

  28.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ w ❌ʮཧ૝ͷઃܭύλʔϯΛςʔϒϧʹฒ΂ͯબఆʯ w ⭕ʮ՝୊Λղܾ͢ΔͨΊʹඞཁͳมߋΛߦ͏ʯ w ਓతϦιʔε΍ઃܭͷকདྷੑͳͲ΋ߟྀͭͭ͠ɺɹ ݱ࣮తͳ൑அ͕ඞཁʹͳΔ

    λʔήοτ͸ʮطଘϓϩμΫτͷϚΠάϨʔτʯ
  29.   (VJEFUPBQQBSDIJUFDUVSFͷུ֓ͱଊ͑ํ ՝୊ᶃ๲ΒΜͩ7JFXͷ࣮૷΁ͷมߋ΍֦ுͷίετ ՝୊ᶄ7JFX͕࣋ͭϩδοΫͷςετ͕ଘࡏ͠ͳ͍ ՝୊ᶅը໘ճస࣌ͳͲͷ"DUJWJUZ࠶ੜ੒΁ͷऑ͞ ઃܭ໘Ͱͷ՝୊ (VJEFUPBQQBSDIJUFDUVSFͰͷݪཧɾݪଇΛࢀߟʹ ՝୊ΛղܾͰ͖Δ࠷খͷ੍໿ΛઃܭʹՃ͑Δ

  30. طଘΞϓϦͷઃܭվྑͷ࣮ྫ  

  31.   طଘΞϓϦͷઃܭվྑ 7JFX "DUJWJUZ'SBHNFOU .PEFM 7JFX "DUJWJUZ'SBHNFOU .PEFM

  32.   طଘΞϓϦͷઃܭվྑ 7JFX "DUJWJUZ'SBHNFOU .PEFM 7JFX.PEFM ""$ w 7JFXϩδοΫΛ੾Γग़͢૚ͷ

    ৽ઃ͸ඞਢ w ͦͷ૚͸"DUJWJUZͷ࠶ੜ੒΍ ը໘ճసͳͲͷߏ੒ͷมߋʹ ڧ͍͜ͱ͕ཁ݅ 7JFX.PEFMΛ࠾༻ "OESPJE"SDIJUFDUVSF$PNQPOFOUT 
  33.   طଘΞϓϦͷઃܭվྑ 7JFX.PEFM ""$ ͸"DUJWJUZͷഁغΛ৐Γӽ͑ͳ͍ PO4BWF*OTUBODF4UBUF 7JFX.PEFM ""$ ʲࢀߟʳ"QQMJDBUJPO

    4JOHMFUPO*OTUBODF ߏ੒ͷมߋʢը໘ճసͳͲʣ "DUJWJUZͷഁغ ϓϩηεͷഁغ
  34. w TBWFE*OTUBODF4UBUFͷߟྀΛڧ੍͢Δ7JFX.PEFMΛ ࡞੒͠ɺݪଇશͯͷ7JFX.PEFM͸͜ΕΛܧঝͤ͞Δ   طଘΞϓϦͷઃܭվྑ ˞0G#VOEMFTBOE7JFX.PEFMTc1SP"OESPJE%FWࢀߟ IUUQTQSPBOESPJEEFWDPNDVTUPNJ[JOHUIFOFXWJFXNPEFMDGCBDG

  35.   طଘΞϓϦͷઃܭվྑ ͍͔ʹ7JFX.PEFMͷอ࣋͢Δσʔλɾঢ়ଶΛ 7JFX "DUJWJUZ'SBHNFOU ʹ൓өͤ͞Δ͔ w 7JFX.PEFM͸"DUJWJUZΑΓੜଘظ͕ؒ௕͍ w

    ΫϥεؒͷΠϯλʔϑΣʔεΛᐆດʹͯ͠͠·͏ͱɺ ੹຿ͷ໌ྎ͞΍ߏ੒ͷมߋ΁ͷݎ࿚ੑ͕٘ਜ਼ʹʜ
  36.   طଘΞϓϦͷઃܭվྑ 7JFX "DUJWJUZ'SBHNFOU 7JFX.PEFM ""$ .PEFM ͜͜ͷΠϯλʔϑΣʔεʹ ੍໿ɾϧʔϧΛઃ͚Δ

  37.   طଘΞϓϦͷઃܭվྑ Πϕϯτʢشൃੑʣ ঢ়ଶʢෆشൃੑʣ w ը໘ભҠ w μΠΞϩάͷදࣔ w

    5PBTU4OBDLCBSͷදࣔ w ಡΈࠐΈதͷεςʔλε w ը໘ͷදࣔ಺༰ ˢͬ͘͟Γݴ͏ͱ ʮϨΠΞ΢τʹ൓өͰ͖Δ΋ͷʯ 7JFXʹ൓ө͢Δ΋ͷ
  38.   طଘΞϓϦͷઃܭվྑ Πϕϯτʢشൃੑʣ ୯ൃͷ௨஌ʹ࠷దԽͨ͠-JWF%BUB w 4JOHMF-JWF&WFOUʢ"SDIJUFDUVSF#MVFQSJOUTΑΓʣ w "DUJWJUZ'SBHNFOUͷϥΠϑαΠΫϧʹԠͨ͡ɹ σʔλ௨஌ʹదͨ͠ʮ-JWF%BUBʯΛܧঝͨ͠΋ͷ

    w ߏ੒ͷมߋޙʹ࠶౓PCTFSWFͯ͠΋௨஌͞Εͳ͍
  39.   طଘΞϓϦͷઃܭվྑ

  40.   طଘΞϓϦͷઃܭվྑ 5JQTΠϕϯτΛෳ਺0CTFSWFSͰ؂ࢹ͍ͨ࣌͠͸ʜʁ w 4JOHMF-JWF&WFOU͸࢖༻ෆՄ w ෳ਺ͷ0CTFSWFSͷ಺ɺҰ͚ͭͩʹ௨஌͞ΕΔڍಈ w 7JFX.PEFM͔Βͷ୯ൃͷΠϕϯτ௨஌ʹ͍ͭͯɹɹ

    4JOHMF-JWF&WFOUͱ͸ผͷख๏΋ଘࡏ͢ΔͷͰཁࢀর ˞-JWF%BUBXJUI4OBDL#BS /BWJHBUJPOBOEPUIFSFWFOUTc"OESPJE%FWFMPQFST.FEJVNࢀߟ
  41.   طଘΞϓϦͷઃܭվྑ ঢ়ଶʢෆشൃੑʣ %BUB#JOEJOHͰ൓ө w ϨΠΞ΢τͷߋ৽͸ݪଇ%BUB#JOEJOHܦ༝ w 6*Πϕϯτ΋%BUB#JOEJOHͰ7JFX.PEFMʹ௨஌

  42.   طଘΞϓϦͷઃܭվྑ Πϕϯτʢشൃੑʣ 4JOHMF-JWF&WFOUͰ໋ྩ ঢ়ଶʢෆشൃੑʣ %BUB#JOEJOHͰ൓ө 7JFX "DUJWJUZ'SBHNFOU 7JFX.PEFM

    ""$ .PEFM
  43.   طଘΞϓϦͷઃܭվྑ 7JFX "DUJWJUZ'SBHNFOU ͷ࣮૷͕࠷খݶʹ

  44.   طଘΞϓϦͷઃܭվྑ w "DUJWJUZ'SBHNFOU͸4JOHMF-JWF&WFOUͷએݴతͳ ؂ࢹͱ%BUB#JOEJOHͷॳظԽΛߦ͏͚ͩ w ߏ੒ͷมߋ࣌΋ϨΠΞ΢τͷදࣔঢ়ଶ͕෮ݩ͞ΕΔ w ෳࡶͳΞχϝʔγϣϯͷ࣮૷ͳͲ͕๲ΒΜͰ΋ɺɹɹ

    7JFXͷ࣮૷͕ഁ୼͢Δ͜ͱ͸ͳͦ͞͏ʜʁ 7JFX "DUJWJUZ'SBHNFOU ͷ࣮૷͕࠷খݶʹ
  45.   طଘΞϓϦͷઃܭվྑ ՝୊ᶃ๲ΒΜͩ7JFXͷ࣮૷΁ͷมߋ΍֦ுͷίετ ՝୊ᶄ7JFX͕࣋ͭϩδοΫͷςετ͕ଘࡏ͠ͳ͍ ՝୊ᶅը໘ճస࣌ͳͲͷ"DUJWJUZ࠶ੜ੒΁ͷऑ͞ ઃܭ໘Ͱͷ՝୊ ઃܭ໘Ͱͷ՝୊ͷղܾΛ௨ͯ͠ɺ (VJEFUPBQQBSDIJUFDUVSFͷݪଇʹ४ڌͰ͖ͨʁ

  46.   طଘΞϓϦͷઃܭվྑ .PEFM 7JFX "DUJWJUZ'SBHNFOU ஈ֊తͳ Ҡߦ͕༰қ 7JFX "DUJWJUZ'SBHNFOU

    7JFX.PEFM ""$
  47.   αϯϓϧΞϓϦ OBLBNVVVKFUQBDLBSDIJUFDUVSFQMBZHSPVOE IUUQTHJUIVCDPNOBLBNVVVKFUQBDLBSDIJUFDUVSFQMBZHSPVOE

  48.   αϯϓϧΞϓϦ w &$ܥΞϓϦʹΑ͋͘Δݸਓ৘ใͷ ೖྗը໘͕୊ࡐ w ϥΫϚͷ࿈བྷઌɾॅॴͷઃఆը໘ Ͱ΋ಉ༷ͷઃܭʹมߋࡁΈ w

    "DUJWJUZͷ࠶ੜ੒ɾߏ੒ͷมߋʹ ର͢Δڧ͞΋֬อͰ͖ͨɻ
  49. ·ͱΊ  

  50.   ·ͱΊ w طଘΞϓϦͷઃܭվྑʹ͍ͭͯͭͷ࣮ྫΛࣔͨ͠ɻ w ઈରతͳਖ਼ղͰ͸ͳ͍͕ɺઃܭʹ੍໿Λ΋ͨΒ͢ɹ ͜ͱͰղফͰ͖ͨ՝୊͸ଟ͔ͬͨɻ w "OESPJEϓϥοτϑΥʔϜ͕஀ੜͯ͠೥ɻɹɹɹɹ

    ࣅͨΑ͏ͳ՝୊Λ࣋ͭϓϩμΫτ΋૿͑ͯ͘ΔͷͰ͸ʁ ͥͻօ͞ΜͷϓϩμΫτͰͷ࣮ྫ΋ฉ͔͍ͤͯͩ͘͞ʜʂ
  51. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ