Slide 1

Slide 1 text

%BHHFSͱ3FBMNΛ ར༻ͨ͠Ϟμϯͳ։ൃ ๺ଜɹྋ

Slide 2

Slide 2 text

ࣗݾ঺հ w ๺ଜɹྋ w ͸ͯͳJEGVOOFMCJU w 5XJUUFSJEFYQFSPQFSP

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

͸ͯͳϒοΫϚʔΫ

Slide 5

Slide 5 text

ژ౎

Slide 6

Slide 6 text

ࠓ೔࿩͢͜ͱ w ϑϨʔϜϫʔΫ͔ΒϩδοΫΛ੾Γ཭͢ w ӬଓԽ w αʔόαΠυͱฒߦͨ͠։ൃ w ϓϩμΫτνΣοΫ

Slide 7

Slide 7 text

ϑϨʔϜϫʔΫ͔Βϩ δοΫΛ੾Γ཭͢

Slide 8

Slide 8 text

ϑϨʔϜϫʔΫ w "OESPJE4%,͕ఏڙ͢ΔɺΞϓϦ΍ը໘ͷϥΠ ϑαΠΫϧͱڧ݁͘ͼ͍ͭͨΫϥε

Slide 9

Slide 9 text

ϩδοΫΛͲ͜ʹॻ͔͘ w º"DUJWJUZ 'SBHNFOUʹ௚઀ॻ͘ w ංେԽɺςετෆՄೳ w ˛$VTUPN7JFXʹ௚઀ॻ͘ w 7JFXͷϩδοΫ͸͜͜ʹॻ͚͹ྑ͍ w ͦΕҎ֎ͷ৔ॴ

Slide 10

Slide 10 text

ͦΕҎ֎ͷ৔ॴʁ w ϩδοΫΛந৅Խͯ͠੾Γग़͢ w d$POUSPMMFS d.BOBHFSͳͲɺϩδοΫ୲౰ ΫϥεΛ࡞Δ

Slide 11

Slide 11 text

ϩδοΫͷந৅ͷ*OTUBODFΛ Ͳ͜Ͱ࡞Δ͔ʁ w ˛ར༻͢Δ"DUJWJUZʹ௚઀ॻ͘ w ݁ͼ͖͕ͭڧ͘ͳΔ w ςετͷ࣌ʹڍಈΛม͍͑ͨͱ͖͸ʁ w ˓ར༻͢Δͷ֎෦Ͱੜ੒ɾ؅ཧ w ґଘͤ͞ͳ͍ w ςετ࣌ʹ͸੾Γସ͑Δɺͱ͍ͬͨ͜ͱ͕༰қ w %*

Slide 12

Slide 12 text

ૉ๿ͳ%* public EntryManager(APIClient apiClient) { this.mAPIClient = apiClient;
 ... }

Slide 13

Slide 13 text

ૉ๿ͳ%*࢖͑ͳ͍໰୊ w "DUJWJUZͱ'SBHNFOUʹରͯ͠͸ແྗ w ίϯετϥΫλͰΠϯελϯε౉ͤͳ͍ w 1BSDFMBCMFʹͯ͠ؤுΕ͹Ͱ͖ͳ͍͜ͱ͸ͳ͍͕ ؤுΓͨ͘ͳ͍ w ͜ͷ໰୊͸%*ίϯςφ͕͋Ε͹ղܾ͢Δ

Slide 14

Slide 14 text

%*ίϯςφ w ґଘ஫ೖΛߦ͏ϑϨʔϜϫʔΫ w खಈͰ࢓૊ΈΛ༻ҙ͠ͳͯ͘ྑ͍ w Πϯελϯε؅ཧ΋ߦͳ͑Δ

Slide 15

Slide 15 text

Ͳͷ%*ίϯςφΛ࢖͏΂͖ ͔ʁ w 3PCP(VJDF w %BHHFS w %BHHFS

Slide 16

Slide 16 text

%BHHFS

Slide 17

Slide 17 text

%BHHFS w IUUQTHJUIVCDPNHPPHMFEBHHFS w %*ίϯςφ w 4RVBSF͕։ൃͯͨ͠%BHHFSͷHPPHMFGPSL

Slide 18

Slide 18 text

%BHHFSͷར఺ w ίϯύΠϧ࣌ʹίʔυੜ੒͠ґଘղܾ w ࣮ߦதͷύϑΥʔϚϯεʹӨڹ͠ͳ͍ w σόοάͰίʔυΛ௥͍΍͍͢

Slide 19

Slide 19 text

%*ͷߏ੒ w .PEVMF w *OTUBODFͷੜ੒ํ๏Λهड़ w $PNQPOFOU w .PEVMF಺ͷ*OTUBODFΛͲ͜ʹJOKFDU͢Δ͔ه ड़ w ֊૚ߏ଄Λ΋ͨͤͯ໾ׂΛ෼୲͠໌֬Խ

Slide 20

Slide 20 text

.PEVMF @Module 
 public class MainModule { ... @Provides
 EntryManager provideEntryManager() { return new EntryManager(mService); } ...

Slide 21

Slide 21 text

$PNQPOFOU @Component(modules = MainModule.class) public interface MainComponent { void inject(MainActivity mainActivity) …

Slide 22

Slide 22 text

*OKFDU public class MainActivity extends AppCompatActivity { @Inject EntryManager mEntryManager; @Override 
 protected void onCreate(Bundle b) { ... ((App) getApplication()) .component() .inject(this); ...

Slide 23

Slide 23 text

5FTU༻.PEVMF @Module 
 public class MainTestModule { ... @Provides
 EntryManager provideEntryManager() { return new EntryManager(mStubService); } ...

Slide 24

Slide 24 text

ςετ༻$PNQPOFOU @Component(modules = MainTestModule.class) public interface MainTestComponent { void inject(EntryManagerTestCase testCase) …

Slide 25

Slide 25 text

*OKFDU ςετ public class EntryManagerTestCase extends InstrumentationTestCase {
 …
 @Inject
 EntryManager mEntryManager;
 … public testGetEntries() { assertEquals( "ΤϯτϦऔಘͰ͖͍ͯΔ", false, mEntryManager.getEntries().isEmpty()); }
 }

Slide 26

Slide 26 text

$PNQPOFOUͷ෼͚ํ w "DUJWJUZ΍'SBHNFOUຖʹ෼͚Δʁ w ਺͕υϯυϯ૿͍͑ͯ͘ w ໾ׂ͝ͱʹ෼͚Δ w ֊૚ߏ଄Λ࡞ͬͯࡉ෼Խ

Slide 27

Slide 27 text

4VC$PNQPOFOU @Component(modules = MainModule.class)
 public interface MainComponent {
 void inject(App app);
 
 // Activities
 void inject(RootActivity rootActivity);
 
 // Fragments
 void inject(MainSettingsFragment mainSettingsFragment);
 
 // Subcomponents
 UserComponent userComponent(UserModule userModule); }

Slide 28

Slide 28 text

4VC$PNQPOFOU @Subcomponent(modules = UserModule.class)
 public interface UserComponent {
 
 // Fragments
 void inject(MyFragment myFragment);
 
 UserController userController();
 }

Slide 29

Slide 29 text

$PNQPOFOUΛऔಘ public class MyFragment extends Fragment { MainComponent mainComponent = App.get(getActivity())
 .getMainComponent(); 
 UserComponent userComponent = mainComponent.userComponent( new UserModule( mainComponent.getRealm(), args.getString(ARGS_USER_ID)));
 userComponent.inject(this); }

Slide 30

Slide 30 text

ӬଓԽ

Slide 31

Slide 31 text

ӬଓԽ͢Δ໨త w 8FC"1*͔ΒͷϨεϙϯεΛӬଓԽ w ΦϑϥΠϯ༻ͷΩϟογϡσʔλͷͨΊ w "DUJWJUZ΍'SBHNFOUͷ࠶ੜ੒࣌ʹ෮ؼ͢ΔͨΊ w ෳ਺ͷը໘Ͱಉ͡σʔλΛදࣔ͢Δͱ͖ͷҰ؏ ੑΛอͪ΍͘͢͢ΔͨΊ

Slide 32

Slide 32 text

ӬଓԽ͢Δखஈ w º4IBSFE1SFGFSFODFTʹೖΕΔ w ˛'JMFʹॻ͖ͩ͢ w ˓42-JUFʹೖΕΔ w ˓3FBMNΛ࢖͏

Slide 33

Slide 33 text

42-JUF w "OESPJEඪ४ͳͷͰ҆৺ײ͕͋Δ w ࣗྗͰॻ͘ͷ͸গʑ໘౗͍͘͞ w 03.࢖͏ʁ w ࢖͍΍͢͞ɺૣ͞ɺ҆ఆɺকདྷੑʜ

Slide 34

Slide 34 text

3FBMN w ։ൃ͕׆ൃ w 42-JUFͷΑ͏ͳ໘౗ͳ͜ͱΛ͠ͳͯ͘ྑ͍ w ˛όʔδϣϯະຬ

Slide 35

Slide 35 text

3FBMNΛ࢖͏ w J04ΞϓϦͱ ՄೳͳݶΓ ڞ௨ͷϞσϧΛ࣋ͪͨ ͍ͨΊ w ։ൃ׆ൃ͔ͩΒԿ͔͋ͬͯ΋ରॲ͞ΕΔͰ͋Ζ ͏

Slide 36

Slide 36 text

3FBMN

Slide 37

Slide 37 text

3FBMN w 42-JUFΛஔ͖׵͑͏Δ.PCJMFEBUBCBTF w 03.ͷػೳ΋࣋ͭ w ߴ଎ w J04Ͱ΋ར༻Մೳ

Slide 38

Slide 38 text

3FBMNΛ࢖͏ new RealmConfiguration.Builder(context)
 .name("realm")
 .schemaVersion(1L)
 .build();

Slide 39

Slide 39 text

3FBMNΛ࢖͏ RealmResults followingEntries = mRealm.where(Entry.class) .equalTo("isFollowing",true) .findAllSortedAsync( "createdAt", Sort.DESCENDING);

Slide 40

Slide 40 text

"DUJWJUZੜ੒࣌ʹҾ͘ public class MainActivity extends AppCompatActivity { … public void onCreate(Bundle savedInstanceState) { mRealmResults = mRealm.where().findAllAsync() … } w ͙͢͞·3FBMN3FTVMUTΛಘΔ w ਖ਼͘͠෮ݩ͢ΔͨΊʹ΋࢖͏

Slide 41

Slide 41 text

"EBQUFSʹ3FBMN3FTVMU public class EntriesAdapter { public EntriesAdapter(RealmResults entries) {
 mEntries = entries;
 mRealmChangeListener = new RealmChangeListener() {
 @Override
 public void onChange() {
 mListItems = getItems();
 EpisodesAdapter.this.notifyDataSetChanged();
 }
 }; …
 } …

Slide 42

Slide 42 text

"EBQUFSʹ3FBMN3FTVMU public class EntriesAdapter { … @Override
 public void onAttachedToRecyclerView(RecyclerView recyclerView) {
 super.onAttachedToRecyclerView(recyclerView);
 mResults.addChangeListener(mRealmChangeListener);
 }
 
 @Override
 public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
 mResults.removeChangeListener(mRealmChangeListener);
 super.onDetachedFromRecyclerView(recyclerView);
 } …

Slide 43

Slide 43 text

"DUJWJUZؒͷσʔλड͚౉͠ Intent intent = new Intent(context, EpisodeActivity.class); intent.putExtra(EXTRA_ID, Id); w 3FBMNͷ*%Λ౉͢͜ͱʹͯ͠͠·͏ w ࠶ੜ੒ʹ΋උ͑ΕΔ͜ͱʹͳΔ

Slide 44

Slide 44 text

3FBMN Λ %BHHFS Ͱ εϨου͝ͱʹ*OKFDU

Slide 45

Slide 45 text

εϨου·ͨ͛ͳ͍໰୊ w 3FBMN*OTUBODF͕࡞੒͞ΕͨεϨου͔Βଞͷ εϨουͰ࢖͑ͳ͍ w ͔͠͠*OKFDU͸PO$SFBUF Ͱߦ͍͍ͨ w ʮผεϨου͕ཉ͍࣌͠ʹ*OKFDU͢Δ࢓૊Έʯ͕ ඞཁ

Slide 46

Slide 46 text

%BHHFSͷ1SPWJEFSΛ࢖͏ … @Inject public EntryPrefetcher(Provider realmProvider) extends ThreadPoolExecutor { mRealmProvider = realmProvider; … private static class Task implements Callable { @Override
 public String call() throws Exception { Realm realm = mRealmProvider.get(); … } …

Slide 47

Slide 47 text

αʔόαΠυ ͱ ฒߦͨ͠։ൃ

Slide 48

Slide 48 text

αʔόαΠυͱฒߦͨ͠։ൃ w "1*͕ඞͣ͠΋ઌߦ͢Δͱ͸ݶΒͳ͍ w μϛʔσʔλΛΞϓϦ಺෦ʹ͔࣋ͭʁ w "1*ʹมߋ͕͋ͬͨ࣌ʹ໘౗ w J04ଆ΋ಉ࣌ʹมߋ͢Δඞཁ͕ग़ͯ͘Δ

Slide 49

Slide 49 text

4UVC4FSWFS

Slide 50

Slide 50 text

4UVC4FSWFS w μϛʔͷϨεϙϯεΛฦ͢αʔόΛ࡞Δ w "1*4DIFNB όϦσʔλͱͯ͠ར༻ w IUUQTHJUIVCDPNIJUPEF"1*4DIFNB

Slide 51

Slide 51 text

4UVC4FSWFS SFTPVSDFMPHJO@SFRVFTU\ UZQFPCKFDU EFTDSJQUJPOϩάΠϯϦΫΤετ QSPQFSUJFT\ FNBJM@BEESFTT\ UZQFTUSJOH EFTDSJQUJPOϝʔϧΞυϨε FYBNQMFBCD!FYBNQMFDPN ^ QBTTXPSE\ UZQFTUSJOH EFTDSJQUJPObύεϫʔυ FYBNQMF1BTTXSE ^ ^ SFRVJSFE<FNBJM@BEESFTT QBTTXPSE> ^

Slide 52

Slide 52 text

ςετͰ΋4UVC4FSWFSΛ ࢖͏ w ˛μϛʔͷ+40/Λ಺෦ʹ࣋ͬͯςετʹར༻ w "1*มΘΔͨͼʹมߋͤͶ͹ͳΒͳ͍ w "1*ͷมߋʹςετ͕ؾ෇͚ͳ͍ w ̋"1*ͷαʔόΛ௚઀ୟ͘ w μϛʔσʔλෆཁ w มߋʹςετ͕ؾ͕ͭ͘

Slide 53

Slide 53 text

ϓϩμΫτνΣοΫ

Slide 54

Slide 54 text

ϓϩμΫτνΣοΫ w ژ౎ɾ౦ژʹΦϑΟε͕͋Δ w ౦ژʹ΋σβΠφʔ͕͍Δ w ख৮Γ͸௚઀৮Εͳ͍ͱΘ͔Βͳ͍

Slide 55

Slide 55 text

#FUB#Z$SBTIMZUJDT KFOLJOT GBTUMBOF

Slide 56

Slide 56 text

#FUB w #FUB#Z$SBTIMZUJDTΛ࢖ͬͯ#FUB഑৴ w ഑৴ͷλΠϛϯά͸KFOLJOTʹ೚ͤΔ

Slide 57

Slide 57 text

KFOLJOT w ϒϥϯνΛݟͯͯɺNBTUFSʹϚʔδ͞ΕͨΒ #FUBΛඈ͹͢ w εΫϦʔϯγϣοτΛࡱͬͯ؆қతͳσβΠϯ֬ ೝ w "1*ຖͷࠩҟ౳Λ֬ೝ w 4MBDLʹ௨஌

Slide 58

Slide 58 text

GBTUMBOF (JUIVC࿈ܞ EBUB\TUBUFTUBUF UBSHFU@VSMUBSHFU@VSM DPOUFYUDPOUFYU EFTDSJQUJPO^ IFBEFST\"VUIPSJ[BUJPOUPLFO\UPLFO^^ &YDPOQPTU VSM IFBEFSTIFBEFST CPEZ EBUBUP@KTPO

Slide 59

Slide 59 text

GBTUMBOF 4MBDL࿈ܞ TMBDL NFTTBHFSPDLFUϏϧυ͕׬ྃ͠·ͨ͠SPDLFU DIBOOFMBQQ TVDDFTTUSVF QBZMPBE\ #VJME%BUF5JNFOFXUP@T ^ EFGBVMU@QBZMPBET<HJU@CSBODI HJU@BVUIPS>

Slide 60

Slide 60 text

ςετ࣮ߦ EFTD3VOTBMMUIFUFTUT MBOFUFTUEP HSBEMF UBTLD$ FOE

Slide 61

Slide 61 text

·ͱΊ w ϑϨʔϜϫʔΫ͔ΒϩδοΫΛ੾Γ཭͢ w ϩδοΫͷந৅Խɺ%BHHFSͰ*OKFDU w ӬଓԽ w 3FBMNΛར༻ w αʔόαΠυͱฒߦͨ͠։ൃ w 4UVC4FSWFSΛར༻ w ϓϩμΫτνΣοΫ w #FUB#Z$SBTIMZUJDT KFOLJOT GBTUMBOF

Slide 62

Slide 62 text

͋Γ͕ͱ͏͍͟͝·ͨ͠