DroidKaigi / conference-app-2018

The Official Conference App for DroidKaigi 2018 Tokyo
Apache License 2.0
1.35k stars 332 forks source link

Divided Dagger module's definition into each Activity's. #501

Closed satorufujiwara closed 6 years ago

satorufujiwara commented 6 years ago

Issue

No issue.

Overview (Required)

Changes

Before

DaggerAppComponent.TopicDetailActivitySubcomponentImpl.class (generated by Dagger)

  private final class TopicDetailActivitySubcomponentImpl
      implements TopicDetailActivityBuilder_ContributeTopicDetailActivity
          .TopicDetailActivitySubcomponent {

    // Omitted some code.

    @SuppressWarnings("unchecked")
    private void initialize(final TopicDetailActivitySubcomponentBuilder builder) {
      this.sessionsFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeSessionsFragment.SessionsFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeSessionsFragment.SessionsFragmentSubcomponent
                    .Builder
                get() {
              return new SessionsFragmentSubcomponentBuilder();
            }
          };
      this.allSessionsFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeAllSessionsFragment.AllSessionsFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeAllSessionsFragment
                    .AllSessionsFragmentSubcomponent.Builder
                get() {
              return new AllSessionsFragmentSubcomponentBuilder();
            }
          };
      this.roomSessionsFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeRoomSessionsFragment.RoomSessionsFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeRoomSessionsFragment
                    .RoomSessionsFragmentSubcomponent.Builder
                get() {
              return new RoomSessionsFragmentSubcomponentBuilder();
            }
          };
      this.searchFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeSearchFragment.SearchFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeSearchFragment.SearchFragmentSubcomponent
                    .Builder
                get() {
              return new SearchFragmentSubcomponentBuilder();
            }
          };
      this.searchSessionsFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeSearchSessionsFragment
                  .SearchSessionsFragmentSubcomponent.Builder>() {
            @Override
            public FragmentBuildersModule_ContributeSearchSessionsFragment
                    .SearchSessionsFragmentSubcomponent.Builder
                get() {
              return new SearchSessionsFragmentSubcomponentBuilder();
            }
          };
      this.searchTopicsFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeSearchTopicsFragment.SearchTopicsFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeSearchTopicsFragment
                    .SearchTopicsFragmentSubcomponent.Builder
                get() {
              return new SearchTopicsFragmentSubcomponentBuilder();
            }
          };
      this.searchSpeakersFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeSearchSpeakersFragment
                  .SearchSpeakersFragmentSubcomponent.Builder>() {
            @Override
            public FragmentBuildersModule_ContributeSearchSpeakersFragment
                    .SearchSpeakersFragmentSubcomponent.Builder
                get() {
              return new SearchSpeakersFragmentSubcomponentBuilder();
            }
          };
      this.favoriteSessionsFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeFavoriteSessionsFragment
                  .FavoriteSessionsFragmentSubcomponent.Builder>() {
            @Override
            public FragmentBuildersModule_ContributeFavoriteSessionsFragment
                    .FavoriteSessionsFragmentSubcomponent.Builder
                get() {
              return new FavoriteSessionsFragmentSubcomponentBuilder();
            }
          };
      this.feedFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeFeedFragment.FeedFragmentSubcomponent.Builder>() {
            @Override
            public FragmentBuildersModule_ContributeFeedFragment.FeedFragmentSubcomponent.Builder
                get() {
              return new FeedFragmentSubcomponentBuilder();
            }
          };
      this.sessionDetailFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeDetailFragment.SessionDetailFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeDetailFragment.SessionDetailFragmentSubcomponent
                    .Builder
                get() {
              return new SessionDetailFragmentSubcomponentBuilder();
            }
          };
      this.mapFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeMapFragment.MapFragmentSubcomponent.Builder>() {
            @Override
            public FragmentBuildersModule_ContributeMapFragment.MapFragmentSubcomponent.Builder
                get() {
              return new MapFragmentSubcomponentBuilder();
            }
          };
      this.aboutThisAppFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeAboutThisAppFragment.AboutThisAppFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeAboutThisAppFragment
                    .AboutThisAppFragmentSubcomponent.Builder
                get() {
              return new AboutThisAppFragmentSubcomponentBuilder();
            }
          };
      this.sponsorsFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeSponsorsFragment.SponsorsFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeSponsorsFragment.SponsorsFragmentSubcomponent
                    .Builder
                get() {
              return new SponsorsFragmentSubcomponentBuilder();
            }
          };
      this.settingsFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeSettingsFragment.SettingsFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeSettingsFragment.SettingsFragmentSubcomponent
                    .Builder
                get() {
              return new SettingsFragmentSubcomponentBuilder();
            }
          };
      this.speakerDetailFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeSpeakerDetailFragment
                  .SpeakerDetailFragmentSubcomponent.Builder>() {
            @Override
            public FragmentBuildersModule_ContributeSpeakerDetailFragment
                    .SpeakerDetailFragmentSubcomponent.Builder
                get() {
              return new SpeakerDetailFragmentSubcomponentBuilder();
            }
          };
      this.topicDetailFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeTopicDetailFragment.TopicDetailFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeTopicDetailFragment
                    .TopicDetailFragmentSubcomponent.Builder
                get() {
              return new TopicDetailFragmentSubcomponentBuilder();
            }
          };
      this.contributorsFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeContributorFragment.ContributorsFragmentSubcomponent
                  .Builder>() {
            @Override
            public FragmentBuildersModule_ContributeContributorFragment
                    .ContributorsFragmentSubcomponent.Builder
                get() {
              return new ContributorsFragmentSubcomponentBuilder();
            }
          };
      this.staffFragmentSubcomponentBuilderProvider =
          new Provider<
              FragmentBuildersModule_ContributeStaffFragment.StaffFragmentSubcomponent.Builder>() {
            @Override
            public FragmentBuildersModule_ContributeStaffFragment.StaffFragmentSubcomponent.Builder
                get() {
              return new StaffFragmentSubcomponentBuilder();
            }
          };
      this.seedInstance = builder.seedInstance;
    }

    private TopicDetailActivity injectTopicDetailActivity(TopicDetailActivity instance) {
      TopicDetailActivity_MembersInjector.injectDispatchingAndroidInjector(
          instance, getDispatchingAndroidInjectorOfFragment());
      TopicDetailActivity_MembersInjector.injectNavigationController(
          instance, getNavigationController());
      TopicDetailActivity_MembersInjector.injectViewModelFactory(
          instance, DaggerAppComponent.this.viewModelFactoryProvider.get());
      TopicDetailActivity_MembersInjector.injectDrawerMenu(instance, getDrawerMenu());
      return instance;
    }

After

DaggerAppComponent.TopicDetailActivitySubcomponentImpl.class

  private final class TopicDetailActivitySubcomponentImpl
      implements TopicDetailActivityBuilder_ContributeTopicDetailActivity
          .TopicDetailActivitySubcomponent {
    private Provider<
            TopicDetailActivityModule_ContributeTopicDetailFragment.TopicDetailFragmentSubcomponent
                .Builder>
        topicDetailFragmentSubcomponentBuilderProvider;

    // Omitted some code.

    @SuppressWarnings("unchecked")
    private void initialize(final TopicDetailActivitySubcomponentBuilder builder) {
      this.topicDetailFragmentSubcomponentBuilderProvider =
          new Provider<
              TopicDetailActivityModule_ContributeTopicDetailFragment
                  .TopicDetailFragmentSubcomponent.Builder>() {
            @Override
            public TopicDetailActivityModule_ContributeTopicDetailFragment
                    .TopicDetailFragmentSubcomponent.Builder
                get() {
              return new TopicDetailFragmentSubcomponentBuilder();
            }
          };
      this.seedInstance = builder.seedInstance;
      this.topicDetailViewModelProvider =
          TopicDetailViewModel_Factory.create(
              DaggerAppComponent.this.provideSessionRepositoryProvider,
              DaggerAppComponent.this.provideSchedulerProvider);
    }

    private Map<Class<? extends ViewModel>, Provider<ViewModel>>
        getMapOfClassOfAndProviderOfViewModel() {
      return Collections.<Class<? extends ViewModel>, Provider<ViewModel>>singletonMap(
          TopicDetailViewModel.class, (Provider) topicDetailViewModelProvider);
    }

    private ViewModelFactory getViewModelFactory() {
      return new ViewModelFactory(getMapOfClassOfAndProviderOfViewModel());
    }

    private TopicDetailActivity injectTopicDetailActivity(TopicDetailActivity instance) {
      TopicDetailActivity_MembersInjector.injectDispatchingAndroidInjector(
          instance, getDispatchingAndroidInjectorOfFragment());
      TopicDetailActivity_MembersInjector.injectNavigationController(
          instance, getNavigationController());
      TopicDetailActivity_MembersInjector.injectViewModelFactory(instance, getViewModelFactory());
      TopicDetailActivity_MembersInjector.injectDrawerMenu(instance, getDrawerMenu());
      return instance;
    }

Benefit

Links

Screenshot

Nothing has changed.

takahirom commented 6 years ago

🆒

konifar commented 6 years ago

Cool! 📝

takahirom commented 6 years ago

It's awesome 👍

takahirom commented 6 years ago

LGTM :+1: Thank you for giving the project a big impact 🥇