Slide 1

Slide 1 text

X © DMM.com w %FQFOEFODZ*OKFDUJPOͱ͸ʢ؆୯ʹʣ w %BHHFS࠶ೖ໳ w %BHHFSͷ"OESPJEαϙʔτ࠶ೖ໳ w γϯάϧϞδϡʔϧͰͷ%BHHFSΛ༻͍ͨ%FQFOEFODZ*OKFDUJPO w ϚϧνϞδϡʔϧͰͷ%FQFOEFODZ*OKFDUJPOͷਏ͞ w %BHHFSΛ࢖ͬͯϚϧνϞδϡʔϧϓϩδΣΫτͰ%*Λ࣮ݱ͢Δ w %ZOBNJD'FBUVSF.PEVMF͕͋Δ࣌ͷ࿩ʢ͕࣌ؒ͋Ε͹ʣ "HFOEB ΰʔϧ ϚϧνϞδϡʔϧͰߏ੒͞ΕͨϓϩδΣΫτͰɺ %BHHFSΛ༻͍ͨ%FQFOEFODZ*OKFDUJPOΛߦ͏ࡍͷ ೰ΈϙΠϯτΛ஌ΓɺͦͷղܾࡦΛཧղ͢Δɻ

Slide 2

Slide 2 text

!LHNZTIJO %SPJE,BJHJ ϚϧνϞδϡʔϧϓϩδΣΫτͰͷ %BHHFSΛ༻͍ͨ %FQFOEFODZ*OKFDUJPO

Slide 3

Slide 3 text

X © DMM.com ࣗݾ঺հ w LHNZTIJOఝٶʢ͗͘Έ΍ʣ w "OESPJEΤϯδχΞ w ߹ಉձࣾ%..DPN$50ࣨॴଐ

Slide 4

Slide 4 text

X © DMM.com ͜ͷηογϣϯͷΰʔϧ

Slide 5

Slide 5 text

X © DMM.com ͜ͷηογϣϯͷΰʔϧ ϚϧνϞδϡʔϧͰߏ੒͞ΕͨϓϩδΣΫτͰɺ %BHHFSΛ༻͍ͨ%FQFOEFODZ*OKFDUJPOΛߦ͏ࡍͷ ೰ΈϙΠϯτΛ஌ΓɺͦͷղܾࡦΛཧղ͢Δɻ

Slide 6

Slide 6 text

X © DMM.com BHFOEB

Slide 7

Slide 7 text

X © DMM.com BHFOEB w %FQFOEFODZ*OKFDUJPOͱ͸ʢ؆୯ʹʣ w %BHHFS࠶ೖ໳ w %BHHFSͷ"OESPJEαϙʔτ࠶ೖ໳ w γϯάϧϞδϡʔϧͰͷ%BHHFSΛ༻͍ͨ%FQFOEFODZ*OKFDUJPO w ϚϧνϞδϡʔϧͰͷ%FQFOEFODZ*OKFDUJPOͷਏ͞ w %BHHFSΛ࢖ͬͯϚϧνϞδϡʔϧϓϩδΣΫτͰ%*Λ࣮ݱ͢Δ w %ZOBNJD'FBUVSF.PEVMF͕͋Δ࣌ͷ࿩

Slide 8

Slide 8 text

X © DMM.com ൃදʹೖΔલʹ ΋͠ηογϣϯΛฉ͍ͯΔதͰɺ Θ͔Βͳ͍ͱ͜ΖͳͲͰ͖ͯ·ͨ͠Βɺ ͥͻ%..DPNͷϒʔε·Ͱ͓ӽ͍ͩ͘͠͞ʂ

Slide 9

Slide 9 text

X © DMM.com %FQFOEFODZ*OKFDUJPOͱ͸

Slide 10

Slide 10 text

X © DMM.com %FQFOEFODZ*OKFDUJPOͱ͸ʢ؆୯ʹʣ ҰݴͰɻ ʮґଘΦϒδΣΫτʯΛʮ஫ೖʯ͢ΔσβΠϯύλʔϯͰ͢ɻ

Slide 11

Slide 11 text

X © DMM.com %FQFOEFODZ*OKFDUJPOͱ͸ʢ؆୯ʹʣ internal class AllergenRepositoryImpl : AllergenRepository { private val apiClient = ApiClient() override fun findAll( ): Single> = apiClient.getAllergens() override fun findById( allergenId: AllergenId ): Maybe = apiClient.getAllergen(allergenId.value) } %*͠ͳ͍

Slide 12

Slide 12 text

X © DMM.com %FQFOEFODZ*OKFDUJPOͱ͸ʢ؆୯ʹʣ internal class AllergenRepositoryImpl @Inject constructor( private val apiClient: ApiClient ) : AllergenRepository { override fun findAll( ): Single> = apiClient.getAllergens() override fun findById( allergenId: AllergenId ): Maybe = apiClient.getAllergen(allergenId.value) } internal class AllergenRepositoryImpl : AllergenRepository { private val apiClient = ApiClient() override fun findAll( ): Single> = apiClient.getAllergens() override fun findById( allergenId: AllergenId ): Maybe = apiClient.getAllergen(allergenId.value) } %*͠ͳ͍ %*͢Δ

Slide 13

Slide 13 text

X © DMM.com %FQFOEFODZ*OKFDUJPOͱ͸ʢ؆୯ʹʣ internal class AllergenRepositoryImpl @Inject constructor( private val apiClient: ApiClient ) : AllergenRepository { override fun findAll( ): Single> = apiClient.getAllergens() override fun findById( allergenId: AllergenId ): Maybe = apiClient.getAllergen(allergenId.value) } internal class AllergenRepositoryImpl : AllergenRepository { private val apiClient = ApiClient() override fun findAll( ): Single> = apiClient.getAllergens() override fun findById( allergenId: AllergenId ): Maybe = apiClient.getAllergen(allergenId.value) } %*͠ͳ͍ %*͢Δ

Slide 14

Slide 14 text

X © DMM.com %FQFOEFODZ*OKFDUJPOͱ͸ʢ؆୯ʹʣ ϝϦοτ w ݁߹͕ૄʹͳΔ w ୯ମςετ͕͠΍͍͢ w ಛఆͷϥΠϒϥϦ΍ϑϨʔϜϫʔΫ΁ͷґଘ౓ΛԼ͛Δ͜ͱ͕Ͱ ͖Δ

Slide 15

Slide 15 text

X © DMM.com ಛఆͷϥΠϒϥϦ΍ϑϨʔϜϫʔΫ΁ͷґଘ౓ΛԼ͛Δ͜ͱ͕Ͱ͖Δ w 7PMMFZPS3FUSPpUPS,UPS$MJFOU w 1JDBTTPPS(MJEF ͳͲͳͲͷґଘ౓Λ۩৅Օॴʹด͡ࠐΊΔ͜ͱͰɺ༰қʹϥΠϒ ϥϦΛ੾Γସ͑Δ͜ͱ͕Ͱ͖Δɻ

Slide 16

Slide 16 text

X © DMM.com ΑΓ͔ͬ͠Γ஌Γ͍ͨํ͸ʜ %BZdࠓ೔͔Β࢝ΊΔґଘੑͷ஫ೖCZLPCBLFJTBO

Slide 17

Slide 17 text

X © DMM.com %BHHFS࠶ೖ໳

Slide 18

Slide 18 text

X © DMM.com ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ʁ

Slide 19

Slide 19 text

X © DMM.com ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ʁ

Slide 20

Slide 20 text

X © DMM.com ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ʁ

Slide 21

Slide 21 text

X © DMM.com ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ʁ

Slide 22

Slide 22 text

X © DMM.com ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ʁ

Slide 23

Slide 23 text

X © DMM.com ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ʁ ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ Ͳ͜ʹɹͳʹΛ *OKFDU͢Δ͔Λ໢ཏ͢Δඞཁ͕͋Δɻ

Slide 24

Slide 24 text

X © DMM.com %BHHFSͰ͸ ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ Ͳ͜ʹɹͳʹΛ *OKFDU͢Δ͔Λ໢ཏ͢Δඞཁ͕͋Δɻ

Slide 25

Slide 25 text

X © DMM.com %BHHFSͰ͸ ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ Ͳ͜ʹɹͳʹΛ *OKFDU͢Δ͔Λ໢ཏ͢Δඞཁ͕͋Δɻ

Slide 26

Slide 26 text

X © DMM.com %BHHFSͰ͸ ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ Ͳ͜ʹɹͳʹΛ *OKFDU͢Δ͔Λ໢ཏ͢Δඞཁ͕͋Δɻ

Slide 27

Slide 27 text

X © DMM.com %BHHFSͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ ˞ɹखॱ̏͸৔߹ʹΑΔ͕ɺ͜͜Ͱ͸؆ུԽͷͨΊʹ͜ͷखॱʹݻఆ͢Δ ˞ɹҎ߱ͷྫͰ͸'SBHNFOU΁ͷ*OKFDUΛର৅ͱ͍ͯ͠Δ͕ɺଞͷΫϥεʹஔ͖׵͑ͯ΋໰୊ͳ͍

Slide 28

Slide 28 text

X © DMM.com %BHHFSͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ ˞ɹखॱ̏͸৔߹ʹΑΔ͕ɺ͜͜Ͱ͸؆ུԽͷͨΊʹ͜ͷखॱʹݻఆ͢Δ ˞ɹҎ߱ͷྫͰ͸'SBHNFOU΁ͷ*OKFDUΛର৅ͱ͍ͯ͠Δ͕ɺଞͷΫϥεʹஔ͖׵͑ͯ΋໰୊ͳ͍

Slide 29

Slide 29 text

X © DMM.com ᶃ.PEVMFΛ༻ҙ͢Δ )PHFܕͷΠϯελϯεΛ͍ͩ͘͞ IPHFΛͲ͏ͧ ʮͳʹΛఏڙ͢Δ͔ʁʯܕͱΠϯελϯεͷඥ෇͚Λߦ͏

Slide 30

Slide 30 text

X © DMM.com ᶃ.PEVMFΛ༻ҙ͢Δ @Module internal abstract class GreetingModule { @Binds abstract fun provideGreeter(impl: GreeterImpl): Greeter } @Module internal class CounterModule { @Singleton @Provides fun provideCounter(): Counter = CounterImpl() } .PEVMFͷॻ͖ํͷྫܕͱΠϯελϯεͷඥ෇͚Λߦ͏

Slide 31

Slide 31 text

X © DMM.com ᶃ.PEVMFΛ༻ҙ͢Δ @Module internal abstract class GreetingModule { @Binds abstract fun provideGreeter(impl: GreeterImpl): Greeter } @Module internal class CounterModule { @Singleton @Provides fun provideCounter(): Counter = CounterImpl() } .PEVMFͷॻ͖ํͷྫܕͱΠϯελϯεͷඥ෇͚Λߦ͏

Slide 32

Slide 32 text

X © DMM.com ᶃ.PEVMFΛ༻ҙ͢Δ @Module internal abstract class GreetingModule { @Binds abstract fun provideGreeter(impl: GreeterImpl): Greeter } @Module internal class CounterModule { @Singleton @Provides fun provideCounter(): Counter = CounterImpl() } .PEVMFͷॻ͖ํͷྫܕͱΠϯελϯεͷඥ෇͚Λߦ͏

Slide 33

Slide 33 text

X © DMM.com ᶃ.PEVMFΛ༻ҙ͢Δ @Module internal abstract class GreetingModule { @Binds abstract fun provideGreeter(impl: GreeterImpl): Greeter } @Module internal class CounterModule { @Singleton @Provides fun provideCounter(): Counter = CounterImpl() } .PEVMFͷॻ͖ํͷྫ

Slide 34

Slide 34 text

X © DMM.com ᶃ.PEVMFΛ༻ҙ͢Δ @Module internal abstract class GreetingModule { @Binds abstract fun provideGreeter(impl: GreeterImpl): Greeter } @Module internal class CounterModule { @Singleton @Provides fun provideCounter(): Counter = CounterImpl() } .PEVMFͷॻ͖ํͷྫܕͱΠϯελϯεͷඥ෇͚Λߦ͏

Slide 35

Slide 35 text

X © DMM.com %BHHFSͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ ˞ɹखॱ̏͸৔߹ʹΑΔ͕ɺ͜͜Ͱ͸؆ུԽͷͨΊʹ͜ͷखॱʹݻఆ͢Δ ˞ɹҎ߱ͷྫͰ͸'SBHNFOU΁ͷ*OKFDUΛର৅ͱ͍ͯ͠Δ͕ɺଞͷΫϥεʹஔ͖׵͑ͯ΋໰୊ͳ͍

Slide 36

Slide 36 text

X © DMM.com %BHHFSͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ ˞ɹखॱ̏͸৔߹ʹΑΔ͕ɺ͜͜Ͱ͸؆ུԽͷͨΊʹ͜ͷखॱʹݻఆ͢Δ ˞ɹҎ߱ͷྫͰ͸'SBHNFOU΁ͷ*OKFDUΛର৅ͱ͍ͯ͠Δ͕ɺଞͷΫϥεʹஔ͖׵͑ͯ΋໰୊ͳ͍

Slide 37

Slide 37 text

X © DMM.com ᶄ$PNQPOFOUΛ༻ҙ͢Δ ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ Ͳ͜ʹɹͳʹΛ *OKFDU͢Δ͔Λ໢ཏ͢Δඞཁ͕͋Δɻ

Slide 38

Slide 38 text

X © DMM.com ᶄ$PNQPOFOUΛ༻ҙ͢Δ ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ Ͳ͜ʹɹͳʹΛ *OKFDU͢Δ͔Λ໢ཏ͢Δඞཁ͕͋Δɻ $PNQPOFOUʹ͸ʮͳʹΛఏڙ͢Δ͔ʯҎ֎Λॻ͘

Slide 39

Slide 39 text

X © DMM.com ᶄ$PNQPOFOUΛ༻ҙ͢Δ ΞϓϦέʔγϣϯͰ%*Λ࣮ݱ͢Δʹ͸ Ͳ͜ʹɹͳʹΛ *OKFDU͢Δ͔Λ໢ཏ͢Δඞཁ͕͋Δɻ $PNQPOFOUʹ͸ʮͳʹΛఏڙ͢Δ͔ʯҎ֎Λॻ͘ ʮͲ͜ʹఏڙ͢Δ͔ʯΛओʹॻ͘

Slide 40

Slide 40 text

X © DMM.com ᶄ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component(modules = [GreetingModule::class]) interface GreetingComponent { fun inject(activity: GreetingActivity) fun inject(fragment: GreetingFragment) fun greeter(): Greeter } $PNQPOFOUͷॻ͖ํͷྫJOKFDUઌΛҾ਺ʹͨؔ͠਺Λఆٛ͢Δ

Slide 41

Slide 41 text

X © DMM.com ᶄ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component(modules = [GreetingModule::class]) interface GreetingComponent { fun inject(activity: GreetingActivity) fun inject(fragment: GreetingFragment) fun greeter(): Greeter } $PNQPOFOUͷॻ͖ํͷྫJOKFDUઌΛҾ਺ʹͨؔ͠਺Λఆٛ͢Δ

Slide 42

Slide 42 text

X © DMM.com ᶄ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component(modules = [GreetingModule::class]) interface GreetingComponent { fun inject(activity: GreetingActivity) fun inject(fragment: GreetingFragment) fun greeter(): Greeter } $PNQPOFOUͷॻ͖ํͷྫJOKFDUઌΛҾ਺ʹͨؔ͠਺Λఆٛ͢Δ

Slide 43

Slide 43 text

X © DMM.com ᶄ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component(modules = [GreetingModule::class]) interface GreetingComponent { fun inject(activity: GreetingActivity) fun inject(fragment: GreetingFragment) fun greeter(): Greeter } $PNQPOFOUͷॻ͖ํͷྫJOKFDUઌΛҾ਺ʹͨؔ͠਺Λఆٛ͢Δ

Slide 44

Slide 44 text

X © DMM.com %BHHFSͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ ˞ɹखॱ̏͸৔߹ʹΑΔ͕ɺ͜͜Ͱ͸؆ུԽͷͨΊʹ͜ͷखॱʹݻఆ͢Δ ˞ɹҎ߱ͷྫͰ͸'SBHNFOU΁ͷ*OKFDUΛର৅ͱ͍ͯ͠Δ͕ɺଞͷΫϥεʹஔ͖׵͑ͯ΋໰୊ͳ͍

Slide 45

Slide 45 text

X © DMM.com %BHHFSͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ ˞ɹखॱ̏͸৔߹ʹΑΔ͕ɺ͜͜Ͱ͸؆ུԽͷͨΊʹ͜ͷखॱʹݻఆ͢Δ ˞ɹҎ߱ͷྫͰ͸'SBHNFOU΁ͷ*OKFDUΛର৅ͱ͍ͯ͠Δ͕ɺଞͷΫϥεʹஔ͖׵͑ͯ΋໰୊ͳ͍

Slide 46

Slide 46 text

X © DMM.com ᶅ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ class Application : android.app.Application(){ lateinit var appComponent: AppComponent override fun onCreate() { super.onCreate() appComponent = DaggerAppComponent.create() } }

Slide 47

Slide 47 text

X © DMM.com ᶅ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ class Application : android.app.Application(){ lateinit var appComponent: AppComponent override fun onCreate() { super.onCreate() appComponent = DaggerAppComponent.create() } }

Slide 48

Slide 48 text

X © DMM.com %BHHFSͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ ˞ɹखॱ̏͸৔߹ʹΑΔ͕ɺ͜͜Ͱ͸؆ུԽͷͨΊʹ͜ͷखॱʹݻఆ͢Δ ˞ɹҎ߱ͷྫͰ͸'SBHNFOU΁ͷ*OKFDUΛର৅ͱ͍ͯ͠Δ͕ɺଞͷΫϥεʹஔ͖׵͑ͯ΋໰୊ͳ͍

Slide 49

Slide 49 text

X © DMM.com %BHHFSͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ ˞ɹखॱ̏͸৔߹ʹΑΔ͕ɺ͜͜Ͱ͸؆ུԽͷͨΊʹ͜ͷखॱʹݻఆ͢Δ ˞ɹҎ߱ͷྫͰ͸'SBHNFOU΁ͷ*OKFDUΛର৅ͱ͍ͯ͠Δ͕ɺଞͷΫϥεʹஔ͖׵͑ͯ΋໰୊ͳ͍

Slide 50

Slide 50 text

X © DMM.com ᶆ֤ॴͰ*OKFDU͢Δ class MainFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { super.onAttach(context) (requireActivity().application as Application) .appComponent.inject(this) } : }

Slide 51

Slide 51 text

X © DMM.com ᶆ֤ॴͰ*OKFDU͢Δ class MainFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { super.onAttach(context) (requireActivity().application as Application) .appComponent.inject(this) } : }

Slide 52

Slide 52 text

X © DMM.com ᶆ֤ॴͰ*OKFDU͢Δ class MainFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { super.onAttach(context) (requireActivity().application as Application) .appComponent.inject(this) } : }

Slide 53

Slide 53 text

X © DMM.com %BHHFSͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ ˞ɹखॱ̏͸৔߹ʹΑΔ͕ɺ͜͜Ͱ͸؆ུԽͷͨΊʹ͜ͷखॱʹݻఆ͢Δ ˞ɹҎ߱ͷྫͰ͸'SBHNFOU΁ͷ*OKFDUΛର৅ͱ͍ͯ͠Δ͕ɺଞͷΫϥεʹஔ͖׵͑ͯ΋໰୊ͳ͍

Slide 54

Slide 54 text

X © DMM.com %BHHFS"OESPJE࠶ೖ໳

Slide 55

Slide 55 text

X © DMM.com %BHHFS"OESPJEͷϞνϕʔγϣϯ class MainFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { super.onAttach(context) (requireActivity().application as Application) .appComponent.inject(this) } : }

Slide 56

Slide 56 text

X © DMM.com %BHHFS"OESPJEͷϞνϕʔγϣϯ class MainFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { super.onAttach(context) (requireActivity().application as Application) .appComponent.inject(this) } : } *OKFDU͞ΕΔଆ͕ɺ*OKFDUPSʹ͍ͭͯͷৄࡉΛ஌ͬͯ͠·͍ͬͯΔɻ

Slide 57

Slide 57 text

X © DMM.com %BHHFS"OESPJEͷϞνϕʔγϣϯ class MainFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { super.onAttach(context) (requireActivity().application as Application) .appComponent.inject(this) } : } *OKFDU͞ΕΔଆ͕ɺ*OKFDUPSʹ͍ͭͯͷৄࡉΛ஌ͬͯ͠·͍ͬͯΔɻ Ͳ͜ʹ*OKFDUPS͕͋Δͷ͔ʁͲͷ*OKFDUPS͕ࣗ෼Λ*OKFDUͰ͖Δͷ͔ʁͳͲ

Slide 58

Slide 58 text

X © DMM.com %BHHFS"OESPJEͷϞνϕʔγϣϯ class MainFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } : } ͜͏͢Ε͹ɺྑͦ͞͏

Slide 59

Slide 59 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU %BHHFSΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 60

Slide 60 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ /FX $PNQPOFOUΛ༻ҙ͢Δ 6QEBUFE "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ 6QEBUFE ֤ॴͰJOKFDU 6QEBUFE EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 61

Slide 61 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 62

Slide 62 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 63

Slide 63 text

X © DMM.com ᶃ.PEVMFΛ༻ҙ͢Δ @Module abstract class AppModule { @Binds abstract fun messageProvider(impl: MessageProviderImpl): MessageProvider }

Slide 64

Slide 64 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 65

Slide 65 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 66

Slide 66 text

X © DMM.com ᶄ'SBHNFOU.PEVMFΛ༻ҙ͢Δ @Module abstract class MainFragmentModule { @ContributesAndroidInjector abstract fun mainFragment(): MainFragment }

Slide 67

Slide 67 text

X © DMM.com ᶄ'SBHNFOU.PEVMFΛ༻ҙ͢Δ @Module abstract class MainFragmentModule { @ContributesAndroidInjector abstract fun mainFragment(): MainFragment }

Slide 68

Slide 68 text

X © DMM.com ᶄ'SBHNFOU.PEVMFΛ༻ҙ͢Δ @Module abstract class MainFragmentModule { @ContributesAndroidInjector abstract fun mainFragment(): MainFragment }

Slide 69

Slide 69 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 70

Slide 70 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 71

Slide 71 text

X © DMM.com ᶅ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component( modules = [ AndroidInjectionModule::class, AppModule::class, MainFragmentModule::class ] ) interface AppComponent : AndroidInjector

Slide 72

Slide 72 text

X © DMM.com ᶅ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component( modules = [ AndroidInjectionModule::class, AppModule::class, MainFragmentModule::class ] ) interface AppComponent : AndroidInjector

Slide 73

Slide 73 text

X © DMM.com ᶅ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component( modules = [ AndroidInjectionModule::class, AppModule::class, MainFragmentModule::class ] ) interface AppComponent : AndroidInjector

Slide 74

Slide 74 text

X © DMM.com ᶅ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component( modules = [ AndroidInjectionModule::class, AppModule::class, MainFragmentModule::class ] ) interface AppComponent : AndroidInjector

Slide 75

Slide 75 text

X © DMM.com ᶅ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component( modules = [ AndroidInjectionModule::class, AppModule::class, MainFragmentModule::class ] ) interface AppComponent : AndroidInjector Ͳ͜ʹ*OKFDU͢Δ͔͸ɺ'SBHNFOU.PEVMF΍"OESPJE*OKFDUPSʹ ୅ସ͞ΕͯΔͷͰॻ͔ͳ͍

Slide 76

Slide 76 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 77

Slide 77 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 78

Slide 78 text

X © DMM.com ᶆ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ class Application : android.app.Application(), HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector: DispatchingAndroidInjector override fun supportFragmentInjector(): AndroidInjector = dispatchingFragmentInjector override fun onCreate() { super.onCreate() DaggerAppComponent.create().inject(this) } }

Slide 79

Slide 79 text

X © DMM.com ᶆ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ class Application : android.app.Application(), HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector: DispatchingAndroidInjector override fun supportFragmentInjector(): AndroidInjector = dispatchingFragmentInjector override fun onCreate() { super.onCreate() DaggerAppComponent.create().inject(this) } }

Slide 80

Slide 80 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 81

Slide 81 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 82

Slide 82 text

X © DMM.com ᶇ֤ॴͰ*OKFDU class MainFragment : Fragment() { @Inject lateinit var messageProvider: MessageProvider override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … }

Slide 83

Slide 83 text

X © DMM.com ᶇ֤ॴͰ*OKFDU class MainFragment : Fragment() { @Inject lateinit var messageProvider: MessageProvider override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … }

Slide 84

Slide 84 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU EBHHFSBOESPJEΛ࢖࣮ͬͨ૷ͷྲྀΕ

Slide 85

Slide 85 text

X © DMM.com ࢓૊Έ $PNQPOFOU w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ w .BJO"DUJWJUZʹJOKFDU͢Δํ๏ w 4VC"DUJWJUZʹJOKFDU͢Δํ๏

Slide 86

Slide 86 text

X © DMM.com ࢓૊Έ $PNQPOFOU w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ w .BJO"DUJWJUZʹJOKFDU͢Δํ๏ w 4VC"DUJWJUZʹJOKFDU͢Δํ๏ w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ w .BJO"DUJWJUZʹJOKFDU͢Δํ๏ w 4VC"DUJWJUZʹJOKFDU͢Δํ๏

Slide 87

Slide 87 text

X © DMM.com ࢓૊Έ $PNQPOFOU w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ w .BJO"DUJWJUZʹJOKFDU͢Δํ๏ w 4VC"DUJWJUZʹJOKFDU͢Δํ๏ w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏

Slide 88

Slide 88 text

X © DMM.com ࢓૊Έ $PNQPOFOU w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ w .BJO"DUJWJUZʹJOKFDU͢Δํ๏ w 4VC"DUJWJUZʹJOKFDU͢Δํ๏ w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector … DaggerAppComponent.create().inject(this) … }

Slide 89

Slide 89 text

X © DMM.com class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } ࢓૊Έ $PNQPOFOU w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ w .BJO"DUJWJUZʹJOKFDU͢Δํ๏ w 4VC"DUJWJUZʹJOKFDU͢Δํ๏ w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏

Slide 90

Slide 90 text

X © DMM.com ࢓૊Έ class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏

Slide 91

Slide 91 text

X © DMM.com ࢓૊Έ class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ class MainFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … }

Slide 92

Slide 92 text

X © DMM.com ࢓૊Έ class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ class MainFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ

Slide 93

Slide 93 text

X © DMM.com ࢓૊Έ class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ class MainFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ

Slide 94

Slide 94 text

X © DMM.com ࢓૊Έ class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ class MainFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ

Slide 95

Slide 95 text

X © DMM.com ࢓૊Έ class MainFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏

Slide 96

Slide 96 text

X © DMM.com class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ ࢓૊Έ class MainFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ

Slide 97

Slide 97 text

X © DMM.com class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w .BJO'SBHNFOUʹJOKFDU͢Δํ๏ w 4VC'SBHNFOUʹJOKFDU͢Δํ๏ ࢓૊Έ class MainFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ

Slide 98

Slide 98 text

X © DMM.com ϚϧνϞδϡʔϧͷ%*Ͱͷਏ͞

Slide 99

Slide 99 text

X © DMM.com ϚϧνϞδϡʔϧͰͷ%* BQQ DPVOUFS HSFFUJOH ͜͏͍͏΋ͷΛ࡞Δ

Slide 100

Slide 100 text

X © DMM.com ϚϧνϞδϡʔϧͰͷ%* ͜͏͍͏΋ͷΛ࡞Δ BQQ DPVOUFS HSFFUJOH $PNQPOFOU͸ͦΕͧΕͰ࣋ͭ

Slide 101

Slide 101 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ

Slide 102

Slide 102 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ

Slide 103

Slide 103 text

X © DMM.com ᶆ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ class Application : HasSupportFragmentInjector, … { @Inject lateinit var dispatchingFragmentInjector DispatchingAndroidInjector() override fun supportFragmentInjector(): AndroidInjector = dispatchingFragmentInjector override fun onCreate() { super.onCreate() DaggerCounterComponent.create().inject(this) DaggerGreetingComponent.create().inject(this) … } }

Slide 104

Slide 104 text

X © DMM.com ᶆ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ class Application : HasSupportFragmentInjector, … { @Inject lateinit var dispatchingFragmentInjector DispatchingAndroidInjector() override fun supportFragmentInjector(): AndroidInjector = dispatchingFragmentInjector override fun onCreate() { super.onCreate() DaggerCounterComponent.create().inject(this) DaggerGreetingComponent.create().inject(this) … } }

Slide 105

Slide 105 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ

Slide 106

Slide 106 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ

Slide 107

Slide 107 text

X © DMM.com ᶇ֤ॴͰ*OKFDU class CounterFragment : Fragment() { @Inject lateinit var counter: Counter override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … } class GreetingFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … }

Slide 108

Slide 108 text

X © DMM.com ᶇ֤ॴͰ*OKFDU class CounterFragment : Fragment() { @Inject lateinit var counter: Counter override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … } class GreetingFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … }

Slide 109

Slide 109 text

X © DMM.com Ͳ͏ͳΔ͔ʁ $PVOUFS'SBHNFOU (SFFUJOH'SBHNFOU

Slide 110

Slide 110 text

X © DMM.com Ͳ͏ͳΔ͔ʁ $PVOUFS'SBHNFOU (SFFUJOH'SBHNFOU

Slide 111

Slide 111 text

X © DMM.com $PNQPOFOUΛॳظԽͷॱ൪ΛೖΕସ͑ͯΈΔͱ class Application : HasSupportFragmentInjector, … { @Inject lateinit var dispatchingFragmentInjector DispatchingAndroidInjector() override fun supportFragmentInjector(): AndroidInjector = dispatchingFragmentInjector override fun onCreate() { super.onCreate() DaggerCounterComponent.create().inject(this) DaggerGreetingComponent.create().inject(this) … } }

Slide 112

Slide 112 text

X © DMM.com $PNQPOFOUΛॳظԽͷॱ൪ΛೖΕସ͑ͯΈΔͱ class Application : HasSupportFragmentInjector, … { @Inject lateinit var dispatchingFragmentInjector DispatchingAndroidInjector() override fun supportFragmentInjector(): AndroidInjector = dispatchingFragmentInjector override fun onCreate() { super.onCreate() DaggerGreetingComponent.create().inject(this) DaggerCounterComponent.create().inject(this) … } }

Slide 113

Slide 113 text

X © DMM.com Ͳ͏ͳΔ͔ʁ $PVOUFS'SBHNFOU (SFFUJOH'SBHNFOU

Slide 114

Slide 114 text

X © DMM.com $SBTI͢Δཧ༝ class Application : HasSupportFragmentInjector, … { @Inject lateinit var dispatchingFragmentInjector DispatchingAndroidInjector() … override fun onCreate() { super.onCreate() DaggerCounterComponent.create().inject(this) DaggerGreetingComponent.create().inject(this) … } }

Slide 115

Slide 115 text

X © DMM.com $SBTI͢Δཧ༝ class Application : HasSupportFragmentInjector, … { @Inject lateinit var dispatchingFragmentInjector DispatchingAndroidInjector() … override fun onCreate() { super.onCreate() DaggerCounterComponent.create().inject(this) DaggerGreetingComponent.create().inject(this) … } }

Slide 116

Slide 116 text

X © DMM.com $SBTI͢Δཧ༝ class Application : HasSupportFragmentInjector, … { @Inject lateinit var dispatchingFragmentInjector DispatchingAndroidInjector() … override fun onCreate() { super.onCreate() DaggerCounterComponent.create().inject(this) DaggerGreetingComponent.create().inject(this) … } }

Slide 117

Slide 117 text

X © DMM.com class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w (SFFUJOH'SBHNFOUʹJOKFDU͢Δํ๏ ࢓૊Έ class CounterFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … }

Slide 118

Slide 118 text

X © DMM.com class Application : HasSupportFragmentInjector { @Inject lateinit var dispatchingFragmentInjector } w (SFFUJOH'SBHNFOUʹJOKFDU͢Δํ๏ ࢓૊Έ class CounterFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … }

Slide 119

Slide 119 text

X © DMM.com %BHHFSΛ࢖ͬͯ ϚϧνϞδϡʔϧϓϩδΣΫτͰ %*Λ࣮ݱ͢Δ

Slide 120

Slide 120 text

X © DMM.com վΊͯ՝୊ͱ͸ʁ ՝୊ "QQMJDBUJPOʹ'SBHNFOU༻ͷ*OKFDUPSΛҰ͔ͭ࣋ͯ͠ͳ͍ͨΊ ʹɺ*OKFDUPS্͕ॻ͖͞Εͯ͠·͏͜ͱ

Slide 121

Slide 121 text

X © DMM.com վΊͯ՝୊ͱ͸ʁ ՝୊ "QQMJDBUJPOʹ'SBHNFOU༻ͷ*OKFDUPSΛҰ͔ͭ࣋ͯ͠ͳ͍ͨΊ ʹɺ*OKFDUPS্͕ॻ͖͞Εͯ͠·͏͜ͱ

Slide 122

Slide 122 text

X © DMM.com վΊͯ՝୊ͱ͸ʁ ՝୊ "QQMJDBUJPOʹ'SBHNFOU༻ͷ*OKFDUPSΛҰ͔ͭ࣋ͯ͠ͳ͍ͨΊ ʹɺ*OKFDUPS্͕ॻ͖͞Εͯ͠·͏͜ͱ

Slide 123

Slide 123 text

X © DMM.com "QQMJDBUJPOͰ࣋ͭͭͷ'SBHNFOU*OKFDUPS͕ɺෳ਺ͷ*OKFDUPS Λ࣋ͭΑ͏ʹ͢Δ ղܾࡦͷҰͭ

Slide 124

Slide 124 text

X © DMM.com ͭͷ*OKFDUPSͷதͰෳ਺ͷ*OKFDUPSΛ࣋ͭΑ͏ʹ͢Δ

Slide 125

Slide 125 text

X © DMM.com ͭͷ*OKFDUPSͷதͰෳ਺ͷ*OKFDUPSΛ࣋ͭΑ͏ʹ͢Δ

Slide 126

Slide 126 text

X © DMM.com ͭͷ*OKFDUPSͷதͰෳ਺ͷ*OKFDUPSΛ࣋ͭΑ͏ʹ͢Δ

Slide 127

Slide 127 text

X © DMM.com ͭͷ*OKFDUPSͷதͰෳ਺ͷ*OKFDUPSΛ࣋ͭΑ͏ʹ͢Δ

Slide 128

Slide 128 text

X © DMM.com class ModuleInjector : AndroidInjector { private val injectors = mutableListOf>() fun addInjector(injector: HasDispatchingInjector) { injectors.add(injector) } fun removeInjector(injector: HasDispatchingInjector) { injectors.remove(injector) } … override fun inject(instance: T) { val wasInjected = injectors.any { it.dispatchingAndroidInjector().maybeInject(instance) } if (!wasInjected) { throw IllegalArgumentException("injection failed") } } } .PEVMF*OKFDUPS

Slide 129

Slide 129 text

X © DMM.com class ModuleInjector : AndroidInjector { private val injectors = mutableListOf>() fun addInjector(injector: HasDispatchingInjector) { injectors.add(injector) } fun removeInjector(injector: HasDispatchingInjector) { injectors.remove(injector) } … override fun inject(instance: T) { val wasInjected = injectors.any { it.dispatchingAndroidInjector().maybeInject(instance) } if (!wasInjected) { throw IllegalArgumentException("injection failed") } } } .PEVMF*OKFDUPS

Slide 130

Slide 130 text

X © DMM.com class ModuleInjector : AndroidInjector { private val injectors = mutableListOf>() fun addInjector(injector: HasDispatchingInjector) { injectors.add(injector) } fun removeInjector(injector: HasDispatchingInjector) { injectors.remove(injector) } … override fun inject(instance: T) { val wasInjected = injectors.any { it.dispatchingAndroidInjector().maybeInject(instance) } if (!wasInjected) { throw IllegalArgumentException("injection failed") } } } .PEVMF*OKFDUPS

Slide 131

Slide 131 text

X © DMM.com class ModuleInjector : AndroidInjector { private val injectors = mutableListOf>() fun addInjector(injector: HasDispatchingInjector) { injectors.add(injector) } fun removeInjector(injector: HasDispatchingInjector) { injectors.remove(injector) } … override fun inject(instance: T) { val wasInjected = injectors.any { it.dispatchingAndroidInjector().maybeInject(instance) } if (!wasInjected) { throw IllegalArgumentException("injection failed") } } } .PEVMF*OKFDUPS interface HasDispatchingInjector { fun dispatchingAndroidInjector(): DispatchingAndroidInjector }

Slide 132

Slide 132 text

X © DMM.com class ModuleInjector : AndroidInjector { private val injectors = mutableListOf>() fun addInjector(injector: HasDispatchingInjector) { injectors.add(injector) } fun removeInjector(injector: HasDispatchingInjector) { injectors.remove(injector) } … override fun inject(instance: T) { val wasInjected = injectors.any { it.dispatchingAndroidInjector().maybeInject(instance) } if (!wasInjected) { throw IllegalArgumentException("injection failed") } } } .PEVMF*OKFDUPS

Slide 133

Slide 133 text

X © DMM.com class ModuleInjector : AndroidInjector { private val injectors = mutableListOf>() fun addInjector(injector: HasDispatchingInjector) { injectors.add(injector) } fun removeInjector(injector: HasDispatchingInjector) { injectors.remove(injector) } … override fun inject(instance: T) { val wasInjected = injectors.any { it.dispatchingAndroidInjector().maybeInject(instance) } if (!wasInjected) { throw IllegalArgumentException("injection failed") } } } .PEVMF*OKFDUPS

Slide 134

Slide 134 text

X © DMM.com EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ /FX $PNQPOFOUΛ༻ҙ͢Δ 6QEBUFE "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ 6QEBUFE ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ

Slide 135

Slide 135 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 136

Slide 136 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 137

Slide 137 text

X © DMM.com ᶃ.PEVMFΛ༻ҙ͢Δ @Module internal abstract class CounterModule { @Singleton @Binds abstract fun provideCounter(impl: CounterImpl): Counter } @Module internal abstract class GreetingModule { @Binds abstract fun provideGreeter(impl: GreeterImpl): Greeter }

Slide 138

Slide 138 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 139

Slide 139 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 140

Slide 140 text

X © DMM.com ᶄ'SBHNFOU.PEVMFΛ༻ҙ͢Δ @Module internal abstract class GreetingFragmentModule { @ContributesAndroidInjector abstract fun greetingFragment(): GreetingFragment } @Module internal abstract class CounterFragmentModule { @ContributesAndroidInjector abstract fun counterFragment(): CounterFragment }

Slide 141

Slide 141 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 142

Slide 142 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 143

Slide 143 text

X © DMM.com ᶅ*OKFDUPSΛ༻ҙ͢Δ class CounterInjector : HasDispatchingInjector { @Inject lateinit var supportFragmentInjector: DispatchingAndroidInjector override fun dispatchingAndroidInjector(): DispatchingAndroidInjector = supportFragmentInjector } class GreetingInjector : HasDispatchingInjector { @Inject lateinit var supportFragmentInjector: DispatchingAndroidInjector override fun dispatchingAndroidInjector(): DispatchingAndroidInjector = supportFragmentInjector }

Slide 144

Slide 144 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 145

Slide 145 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 146

Slide 146 text

X © DMM.com ᶆ$PNQPOFOUΛ༻ҙ͢Δ @Singleton @Component( modules = [ AndroidInjectionModule::class, CounterModule::class, CounterFragmentModule::class]) interface CounterComponent : AndroidInjector @Singleton @Component( modules = [ AndroidInjectionModule::class, GreetingModule::class, GreetingFragmentModule::class]) interface GreetingComponent : AndroidInjector

Slide 147

Slide 147 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 148

Slide 148 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 149

Slide 149 text

X © DMM.com ᶇ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ͢Δ class Application : android.app.Application(), HasSupportFragmentInjector { private val fragmentInjector = ModuleInjector() override fun supportFragmentInjector(): AndroidInjector = fragmentInjector override fun onCreate() { super.onCreate() val counterInjector = CounterInjector() DaggerCounterComponent.create().inject(counterInjector) val greetingInjector = GreetingInjector() DaggerGreetingComponent.create().inject(greetingInjector) fragmentInjector.addInjector(counterInjector) fragmentInjector.addInjector(greetingInjector) } }

Slide 150

Slide 150 text

X © DMM.com class Application : android.app.Application(), HasSupportFragmentInjector { private val fragmentInjector = ModuleInjector() override fun supportFragmentInjector(): AndroidInjector = fragmentInjector override fun onCreate() { super.onCreate() val counterInjector = CounterInjector() DaggerCounterComponent.create().inject(counterInjector) val greetingInjector = GreetingInjector() DaggerGreetingComponent.create().inject(greetingInjector) fragmentInjector.addInjector(counterInjector) fragmentInjector.addInjector(greetingInjector) } } ᶇ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ͢Δ

Slide 151

Slide 151 text

X © DMM.com class Application : android.app.Application(), HasSupportFragmentInjector { private val fragmentInjector = ModuleInjector() override fun supportFragmentInjector(): AndroidInjector = fragmentInjector override fun onCreate() { super.onCreate() val counterInjector = CounterInjector() DaggerCounterComponent.create().inject(counterInjector) val greetingInjector = GreetingInjector() DaggerGreetingComponent.create().inject(greetingInjector) fragmentInjector.addInjector(counterInjector) fragmentInjector.addInjector(greetingInjector) } } ᶇ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ͢Δ

Slide 152

Slide 152 text

X © DMM.com class Application : android.app.Application(), HasSupportFragmentInjector { private val fragmentInjector = ModuleInjector() override fun supportFragmentInjector(): AndroidInjector = fragmentInjector override fun onCreate() { super.onCreate() val counterInjector = CounterInjector() DaggerCounterComponent.create().inject(counterInjector) val greetingInjector = GreetingInjector() DaggerGreetingComponent.create().inject(greetingInjector) fragmentInjector.addInjector(counterInjector) fragmentInjector.addInjector(greetingInjector) } } ᶇ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ͢Δ

Slide 153

Slide 153 text

X © DMM.com class Application : android.app.Application(), HasSupportFragmentInjector { private val fragmentInjector = ModuleInjector() override fun supportFragmentInjector(): AndroidInjector = fragmentInjector override fun onCreate() { super.onCreate() val counterInjector = CounterInjector() DaggerCounterComponent.create().inject(counterInjector) val greetingInjector = GreetingInjector() DaggerGreetingComponent.create().inject(greetingInjector) fragmentInjector.addInjector(counterInjector) fragmentInjector.addInjector(greetingInjector) } } ᶇ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ͢Δ

Slide 154

Slide 154 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 155

Slide 155 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 156

Slide 156 text

X © DMM.com ᶈ֤ॴͰ*OKFDU class CounterFragment : Fragment() { @Inject lateinit var counter: Counter override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … } class GreetingFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … }

Slide 157

Slide 157 text

X © DMM.com ྲྀΕ

Slide 158

Slide 158 text

X © DMM.com ྲྀΕ

Slide 159

Slide 159 text

X © DMM.com ྲྀΕ class Application : …, HasSupportFragmentInjector { private val moduleFragmentInjector … }

Slide 160

Slide 160 text

X © DMM.com ྲྀΕ class Application : …, HasSupportFragmentInjector { private val moduleFragmentInjector … }

Slide 161

Slide 161 text

X © DMM.com ྲྀΕ class Application : …, HasSupportFragmentInjector { private val moduleFragmentInjector … }

Slide 162

Slide 162 text

X © DMM.com ྲྀΕ class Application : …, HasSupportFragmentInjector { private val moduleFragmentInjector … } class CounterFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … }

Slide 163

Slide 163 text

X © DMM.com ྲྀΕ class Application : …, HasSupportFragmentInjector { private val moduleFragmentInjector … } class CounterFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ

Slide 164

Slide 164 text

X © DMM.com ྲྀΕ class Application : …, HasSupportFragmentInjector { private val moduleFragmentInjector … } class CounterFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ

Slide 165

Slide 165 text

X © DMM.com ྲྀΕ class Application : …, HasSupportFragmentInjector { private val moduleFragmentInjector … } class CounterFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ

Slide 166

Slide 166 text

X © DMM.com ྲྀΕ class Application : …, HasSupportFragmentInjector { private val moduleFragmentInjector … } class CounterFragment : Fragment() { ɹɹ… AndroidSupportInjection.inject(this) … } class MainActivity : AppCompatActivity() { … } HasSupportFragmentInjectorΛ࣮૷ͯ͠Δ͔ʁ

Slide 167

Slide 167 text

X © DMM.com %ZOBNJD'FBUVSF.PEVMF

Slide 168

Slide 168 text

X © DMM.com %ZOBNJD'FBUVSF.PEVMF͕͋Δ࣌ͷ%* BQQ DPVOUFS HSFFUJOH ͍··Ͱ

Slide 169

Slide 169 text

X © DMM.com %ZOBNJD'FBUVSF.PEVMF͕͋Δ࣌ͷ%* BQQ DPVOUFS HSFFUJOH HSFFUJOHΛEZOBNJDGFBUVSFʹ BQQ DPVOUFS HSFFUJOH ͍··Ͱ

Slide 170

Slide 170 text

X © DMM.com %ZOBNJD'FBUVSF.PEVMF͕͋Δ࣌ͷ%* BQQ DPVOUFS HSFFUJOH HSFFUJOHΛEZOBNJDGFBUVSFʹ BQQ DPVOUFS HSFFUJOH ͍··Ͱ

Slide 171

Slide 171 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 172

Slide 172 text

X © DMM.com .PEVMFΛ༻ҙ͢Δ 'SBHNFOU.PEVMFΛ༻ҙ͢Δ *OKFDUPSΛ༻ҙ͢Δ $PNQPOFOUΛ༻ҙ͢Δ "QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ ֤ॴͰJOKFDU ࠓ·Ͱͱಉ͡खॱͰɺEBHHFSBOESPJEΛ࢖࣮ͬͯ૷ͯ͠ΈΔ EBHHFSBOESPJEͰ%FQFOEFODZ*OKFDUJPO͢Δ NVMUJNPEVMF

Slide 173

Slide 173 text

X © DMM.com ᶇ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ͢Δ class Application : android.app.Application(), HasSupportFragmentInjector { private val fragmentInjector = ModuleInjector() override fun supportFragmentInjector(): AndroidInjector = fragmentInjector override fun onCreate() { super.onCreate() val counterInjector = CounterInjector() DaggerCounterComponent.create().inject(counterInjector) val greetingInjector = GreetingInjector() DaggerGreetingComponent.create().inject(greetingInjector) fragmentInjector.addInjector(counterInjector) fragmentInjector.addInjector(greetingInjector) } }

Slide 174

Slide 174 text

X © DMM.com ᶇ"QQMJDBUJPOPO$SFBUFͰ$PNQPOFOUΛॳظԽ͢Δ class Application : android.app.Application(), HasSupportFragmentInjector { private val fragmentInjector = ModuleInjector() override fun supportFragmentInjector(): AndroidInjector = fragmentInjector override fun onCreate() { super.onCreate() val counterInjector = CounterInjector() DaggerCounterComponent.create().inject(counterInjector) val greetingInjector = GreetingInjector() DaggerGreetingComponent.create().inject(greetingInjector) fragmentInjector.addInjector(counterInjector) fragmentInjector.addInjector(greetingInjector) } }

Slide 175

Slide 175 text

X © DMM.com "QQMJDBUJPOPO$SFBUFҎ߱ͷద੾ͳλΠϛϯάͰ JOKFDUPSΛੜ੒ͯ͠ɺNPEVMF*OKFDUPSʹ௥Ճ͢Δ ղܾࡦͷҰͭ

Slide 176

Slide 176 text

X © DMM.com "QQMJDBUJPOPO$SFBUFҎ߱ͷద੾ͳλΠϛϯάͰ JOKFDUPSΛੜ੒ͯ͠ɺNPEVMF*OKFDUPSʹ௥Ճ͢Δ ղܾࡦͷҰͭ

Slide 177

Slide 177 text

X © DMM.com ͨͱ͑͹ɺ͜Μͳؔ਺Λ࡞Δ object GreetingInjection { fun inject(fragment: Fragment) { val application = fragment.requireActivity().application as Application if (application.moduleFragmentInjector.injectors().all { it !is GreetingInjector }) { val injector = GreetingInjector() val component = DaggerGreetingComponent.builder() .counter(application.counterComponent().counter()) .build() component.inject(injector) application.addFragmentInjector(injector) } AndroidSupportInjection.inject(fragment) } }

Slide 178

Slide 178 text

X © DMM.com ͨͱ͑͹ɺ͜Μͳؔ਺Λ࡞Δ object GreetingInjection { fun inject(fragment: Fragment) { val application = fragment.requireActivity().application as Application if (application.moduleFragmentInjector.injectors().all { it !is GreetingInjector }) { val injector = GreetingInjector() val component = DaggerGreetingComponent.builder() .counter(application.counterComponent().counter()) .build() component.inject(injector) application.addFragmentInjector(injector) } AndroidSupportInjection.inject(fragment) } }

Slide 179

Slide 179 text

X © DMM.com ͨͱ͑͹ɺ͜Μͳؔ਺Λ࡞Δ object GreetingInjection { fun inject(fragment: Fragment) { val application = fragment.requireActivity().application as Application if (application.moduleFragmentInjector.injectors().all { it !is GreetingInjector }) { val injector = GreetingInjector() val component = DaggerGreetingComponent.builder() .counter(application.counterComponent().counter()) .build() component.inject(injector) application.addFragmentInjector(injector) } AndroidSupportInjection.inject(fragment) } }

Slide 180

Slide 180 text

X © DMM.com ͨͱ͑͹ɺ͜Μͳؔ਺Λ࡞Δ object GreetingInjection { fun inject(fragment: Fragment) { val application = fragment.requireActivity().application as Application if (application.moduleFragmentInjector.injectors().all { it !is GreetingInjector }) { val injector = GreetingInjector() val component = DaggerGreetingComponent.builder() .counter(application.counterComponent().counter()) .build() component.inject(injector) application.addFragmentInjector(injector) } AndroidSupportInjection.inject(fragment) } }

Slide 181

Slide 181 text

X © DMM.com ͨͱ͑͹ɺ͜Μͳؔ਺Λ࡞Δ object GreetingInjection { fun inject(fragment: Fragment) { val application = fragment.requireActivity().application as Application if (application.moduleFragmentInjector.injectors().all { it !is GreetingInjector }) { val injector = GreetingInjector() val component = DaggerGreetingComponent.builder() .counter(application.counterComponent().counter()) .build() component.inject(injector) application.addFragmentInjector(injector) } AndroidSupportInjection.inject(fragment) } } "DUJWJUZʹNPEVMF*OKFDUPS͕͋Δ৔߹Λߟྀͯ͠ɺ "OESPJE4VQQPSU*OKFDUJPOͱಉ͡Α͏ͳ࣮૷ʹ͢Δͷ΋Մ

Slide 182

Slide 182 text

X © DMM.com ͨͱ͑͹ɺ͜Μͳؔ਺Λ࡞Δ object GreetingInjection { fun inject(fragment: Fragment) { val application = fragment.requireActivity().application as Application if (application.moduleFragmentInjector.injectors().all { it !is GreetingInjector }) { val injector = GreetingInjector() val component = DaggerGreetingComponent.builder() .counter(application.counterComponent().counter()) .build() component.inject(injector) application.addFragmentInjector(injector) } AndroidSupportInjection.inject(fragment) } } ˞"DUJWJUZͰ*OKFDUPSΛ࣋ͭͱ͖͸͜ͷํ๏ͩͱ͏·͍͔͘ͳ͍ͷͰ ৚݅෼ذ͢Δඞཁ͕͋Γ·͢ʂ

Slide 183

Slide 183 text

X © DMM.com ͦ͏͢ΔͱɺJOKFDUઌ͸͜ͷมߋ͚ͩͰࠓ·Ͱ௨Γಈ͘Α͏ʹͳΔ class GreetingFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { GreetingInjection.inject(this) super.onAttach(context) } … } class GreetingFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … }

Slide 184

Slide 184 text

X © DMM.com ͦ͏͢ΔͱɺJOKFDUઌ͸͜ͷมߋ͚ͩͰࠓ·Ͱ௨Γಈ͘Α͏ʹͳΔ class GreetingFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { GreetingInjection.inject(this) super.onAttach(context) } … } class GreetingFragment : Fragment() { @Inject lateinit var greeter: Greeter override fun onAttach(context: Context?) { AndroidSupportInjection.inject(this) super.onAttach(context) } … }

Slide 185

Slide 185 text

X © DMM.com ࿩ͨ͜͠ͱৼΓฦΓ

Slide 186

Slide 186 text

X © DMM.com ࿩ͨ͜͠ͱৼΓฦΓ w %FQFOEFODZ*OKFDUJPOͱ͸ w %BHHFSͷ࢖͍ํͷҰྫɺखॱɺ࢓૊Έ w %BHHFS"OESPJEαϙʔτͷ࢖͍ํͷҰྫɺखॱɺ࢓૊Έ w ͦͷ··Ͱ͸ϚϧνϞδϡʔϧରԠͰ͖ͳ͍έʔε͕͋Δ͜ͱ w .PEVMF*OKFDUPSΛಋೖ͢Δ͜ͱͰରԠͰ͖Δ͜ͱ w %ZOBNJD'FBUVSF.PEVMF࣌͸ɺద੾ͳλΠϛϯάͰ*OKFDUPSΛ .PEVMF*OKFDUPSʹࠩ͠ࠐΜͰ͋͛Δඞཁ͕͋Δ͜ͱ

Slide 187

Slide 187 text

͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠