I'm working on a project and we use Dagger2. I wonder if it is advisable to use it in all our classes to avoid doing new
when instantiating them. For what I am reading it is only necessary when the object instance is created in the constructor.
public class WeatherForecaster {
private final LocationService locationService;
public WeatherForecaster() {
this.locationService = new LocationService();
}
}
My question is using a class like this, for example:
public class SocialControler{
private ImageView twitterLogo;
private ImageView googleLogo;
public SocialControler(ImageView twitter, ImageView google){
twitterLogo = twitter;
googleLogo = google;
}
//Getters and Setters
}
When I instantiate the class in my Activity
I have something like:
SocialControler mSocial = new SocialControler(mTwitterLogo, mGoogleLogo);
Is it necessary to inject the class SocialControler
(that does not build any object in its constructor) in my Activity
without making new
by annotation @inject
?