droidkaigi2016

8928b5277aa7234dbca4ff782952343a?s=47 funnelbit
February 18, 2016

 droidkaigi2016

8928b5277aa7234dbca4ff782952343a?s=128

funnelbit

February 18, 2016
Tweet

Transcript

  1. 3.
  2. 5.
  3. 16.
  4. 20.

    .PEVMF @Module 
 public class MainModule { ... @Provides
 EntryManager

    provideEntryManager() { return new EntryManager(mService); } ...
  5. 22.

    *OKFDU public class MainActivity extends AppCompatActivity { @Inject EntryManager mEntryManager;

    @Override 
 protected void onCreate(Bundle b) { ... ((App) getApplication()) .component() .inject(this); ...
  6. 23.

    5FTU༻.PEVMF @Module 
 public class MainTestModule { ... @Provides
 EntryManager

    provideEntryManager() { return new EntryManager(mStubService); } ...
  7. 25.

    *OKFDU ςετ public class EntryManagerTestCase extends InstrumentationTestCase {
 …
 @Inject


    EntryManager mEntryManager;
 … public testGetEntries() { assertEquals( "ΤϯτϦऔಘͰ͖͍ͯΔ", false, mEntryManager.getEntries().isEmpty()); }
 }
  8. 27.

    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); }
  9. 28.

    4VC$PNQPOFOU @Subcomponent(modules = UserModule.class)
 public interface UserComponent {
 
 //

    Fragments
 void inject(MyFragment myFragment);
 
 UserController userController();
 }
  10. 29.

    $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); }
  11. 30.
  12. 36.
  13. 40.

    "DUJWJUZੜ੒࣌ʹҾ͘ public class MainActivity extends AppCompatActivity { … public void

    onCreate(Bundle savedInstanceState) { mRealmResults = mRealm.where().findAllAsync() … } w ͙͢͞·3FBMN3FTVMUTΛಘΔ w ਖ਼͘͠෮ݩ͢ΔͨΊʹ΋࢖͏
  14. 41.

    "EBQUFSʹ3FBMN3FTVMU public class EntriesAdapter { public EntriesAdapter(RealmResults<Entry> entries) {
 mEntries

    = entries;
 mRealmChangeListener = new RealmChangeListener() {
 @Override
 public void onChange() {
 mListItems = getItems();
 EpisodesAdapter.this.notifyDataSetChanged();
 }
 }; …
 } …
  15. 42.

    "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);
 } …
  16. 46.

    %BHHFSͷ1SPWJEFSΛ࢖͏ … @Inject public EntryPrefetcher(Provider<Realm> realmProvider) extends ThreadPoolExecutor { mRealmProvider

    = realmProvider; … private static class Task implements Callable<String> { @Override
 public String call() throws Exception { Realm realm = mRealmProvider.get(); … } …
  17. 51.

    4UVC4FSWFS SFTPVSDFMPHJO@SFRVFTU\ UZQFPCKFDU  EFTDSJQUJPOϩάΠϯϦΫΤετ  QSPQFSUJFT\ FNBJM@BEESFTT\ UZQFTUSJOH 

    EFTDSJQUJPOϝʔϧΞυϨε  FYBNQMFBCD!FYBNQMFDPN  ^  QBTTXPSE\ UZQFTUSJOH  EFTDSJQUJPObύεϫʔυ  FYBNQMF1BTTXSE  ^  ^  SFRVJSFE<FNBJM@BEESFTT QBTTXPSE>  ^
  18. 59.

    GBTUMBOF 4MBDL࿈ܞ TMBDL  NFTTBHFSPDLFUϏϧυ͕׬ྃ͠·ͨ͠SPDLFU  DIBOOFMBQQ  TVDDFTTUSVF 

    QBZMPBE\ #VJME%BUF5JNFOFXUP@T  ^  EFGBVMU@QBZMPBET<HJU@CSBODI HJU@BVUIPS>
  19. 61.

    ·ͱΊ w ϑϨʔϜϫʔΫ͔ΒϩδοΫΛ੾Γ཭͢ w ϩδοΫͷந৅Խɺ%BHHFSͰ*OKFDU w ӬଓԽ w 3FBMNΛར༻ w

    αʔόαΠυͱฒߦͨ͠։ൃ w 4UVC4FSWFSΛར༻ w ϓϩμΫτνΣοΫ w #FUB#Z$SBTIMZUJDT KFOLJOT GBTUMBOF