I want to ask how to do the injection of a constructor that doesn't have any parameters. I have come across this problem but unable to find a solution. Here is my repo class
public class UrlsRepository {
private UrlsSource urlsSource;
@Inject
public UrlsRepository(UrlsSource urlsSource){
this.urlsSource = urlsSource;
}
public String getLandingUrl(){
return urlsSource.getLoginUrl();
}
public String[] getDashboardUrls(){
return urlsSource.getDashboardUrls();
}
}
Here is the interface
public interface UrlsSource{
String getLoginUrl();
String[] getDashboardUrls();
}
and below is the implementation
@Singleton
public class LocalUrlsSource implements UrlsSource {
@Inject
public LocalUrlsSource(){}
@Override
public String getLoginUrl() {
return Properties.LOGIN_URL;
}
@Override
public String[] getDashboardUrls() {
return Properties.DASHBOARD_URLS;
}
}
Now inside my main activity, I'm injecting UrlsRepository but it's null. Please guide.
public class MainActivity extends Activity implements MainPresenter.View {
@Inject
UrlsRepository urlsRepository;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}