This example contains initially 3 java files:
- SearchApp.java Has the main method
- SearchInPage.java Perfoms the search of a keyword in a string
- HttpClient.java Fetch a webpage
SearchInPage has a dependency on HttpClient, this example is to show how Dagger 2 can be used as Dependency Injection framework.
With Dagger 2 we change the dependency by adding the @Inject annotation, and we add 2 more clases: a Module and a Component which will be used by Dagger 2 to generate the required code to satisfy the dependency injection