iammert / dagger-android-injection

Sample project explains Dependency Injection in Android using dagger-android framework.
515 stars 130 forks source link

Question about AppComponent.java #10

Open davida5 opened 6 years ago

davida5 commented 6 years ago

Hi, thanks for an amazing example, I have a question about two lines in the AppComponent.java, see below, what is the purpose of these lines? without these lines the app seems to work fine

    void inject(AndroidSampleApp app);

    @Override
    void inject(DaggerApplication instance);
badoualy commented 6 years ago

The second one is useless because it's just a redeclaration of a method in the AndroidInjector interface. The first one is here useless because the injected fields are in the DaggerApplication, so the content of inject is generated by looking the DaggerApplication class, so upcasting the app at runtime by calling this one will work