use of javax.inject.Singleton in project dagger by square.
the class InjectAdapterProcessor method writeInjectAdapterConstructor.
private MethodSpec writeInjectAdapterConstructor(ExecutableElement constructor, TypeElement type, ClassName strippedTypeName) {
String key = (constructor != null) ? GeneratorKeys.get(type.asType()) : null;
String membersKey = GeneratorKeys.rawMembersKey(type.asType());
boolean singleton = type.getAnnotation(Singleton.class) != null;
return MethodSpec.constructorBuilder().addModifiers(PUBLIC).addStatement("super($S, $S, $N, $T.class)", key, membersKey, (singleton ? "IS_SINGLETON" : "NOT_SINGLETON"), strippedTypeName).build();
}
use of javax.inject.Singleton in project SongkickInterview by pakoito.
the class NetworkModule method provideOkHttp.
@Provides
@Singleton
OkHttpClient provideOkHttp(final Cache cache, LoggerInterceptor loggerInterceptor, StethoInterceptor stethoInterceptor) {
final OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setCache(cache);
okHttpClient.networkInterceptors().add(loggerInterceptor);
okHttpClient.networkInterceptors().add(stethoInterceptor);
okHttpClient.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
okHttpClient.setReadTimeout(DEFAULT_READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
okHttpClient.setWriteTimeout(DEFAULT_WRITE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
return okHttpClient;
}
use of javax.inject.Singleton in project ngAndroid by davityle.
the class UtilsModule method messageUtils.
@Provides
@Singleton
public MessageUtils messageUtils(ProcessingEnvironment processingEnvironment) {
if (this.messageUtils == null || this.processingEnvironment != processingEnvironment) {
this.messageUtils = new MessageUtils(processingEnvironment);
this.processingEnvironment = processingEnvironment;
}
return messageUtils;
}
use of javax.inject.Singleton in project Varis-Android by dkhmelenko.
the class TestNetworkModule method provideGitHubRestClient.
@Singleton
@Provides
public GitHubRestClient provideGitHubRestClient() {
GitHubRestClient gitHubRestClient = mock(GitHubRestClient.class);
GithubApiService githubApiService = mock(GithubApiService.class);
Mockito.when(gitHubRestClient.getApiService()).thenReturn(githubApiService);
return gitHubRestClient;
}
use of javax.inject.Singleton in project Varis-Android by dkhmelenko.
the class TestNetworkModule method provideTravisRestClient.
@Singleton
@Provides
public TravisRestClient provideTravisRestClient() {
TravisRestClient travisRestClient = mock(TravisRestClient.class);
TravisApiService apiService = mock(TravisApiService.class);
Mockito.when(travisRestClient.getApiService()).thenReturn(apiService);
return travisRestClient;
}
Aggregations