Search in sources :

Example 21 with Provides

use of dagger.Provides 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;
}
Also used : MessageUtils(com.github.davityle.ngprocessor.util.MessageUtils) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 22 with Provides

use of dagger.Provides in project Varis-Android by dkhmelenko.

the class TestNetworkModule method provideTravisRestClient.

@Singleton
@Provides
public TravisRestClient provideTravisRestClient() {
    TravisRestClient travisRestClient = Mockito.mock(TravisRestClient.class);
    TravisApiService apiService = Mockito.mock(TravisApiService.class);
    Mockito.when(travisRestClient.getApiService()).thenReturn(apiService);
    return travisRestClient;
}
Also used : TravisRestClient(com.khmelenko.lab.varis.network.retrofit.travis.TravisRestClient) TravisApiService(com.khmelenko.lab.varis.network.retrofit.travis.TravisApiService) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 23 with Provides

use of dagger.Provides in project Varis-Android by dkhmelenko.

the class TestNetworkModule method provideGitHubRestClient.

@Singleton
@Provides
public GitHubRestClient provideGitHubRestClient() {
    GitHubRestClient gitHubRestClient = Mockito.mock(GitHubRestClient.class);
    GithubApiService githubApiService = Mockito.mock(GithubApiService.class);
    Mockito.when(gitHubRestClient.getApiService()).thenReturn(githubApiService);
    return gitHubRestClient;
}
Also used : GitHubRestClient(com.khmelenko.lab.varis.network.retrofit.github.GitHubRestClient) GithubApiService(com.khmelenko.lab.varis.network.retrofit.github.GithubApiService) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 24 with Provides

use of dagger.Provides in project Just-Another-Android-App by athkalia.

the class NetworkModule method provideOkHttpClient.

@Provides
@Singleton
public static OkHttpClient provideOkHttpClient(PropertiesManager propertiesManager, HttpLoggingInterceptor httpLoggingInterceptor, List<Interceptor> networkInterceptors, BaseUrlInterceptor baseUrlInterceptor) {
    final OkHttpClient.Builder okHttpBuilder = new OkHttpClient.Builder();
    // Logs network calls for debug builds
    okHttpBuilder.addInterceptor(httpLoggingInterceptor);
    // Adds authentication headers when required in network calls
    okHttpBuilder.addInterceptor(new AuthenticationInterceptor(propertiesManager));
    // Helps with changing base url of network calls in espresso tests to the MockWebServer base url.
    okHttpBuilder.addInterceptor(baseUrlInterceptor);
    // For release builds nothing is added, the list is empty. For debug builds Stetho interceptor is added.
    for (Interceptor networkInterceptor : networkInterceptors) {
        okHttpBuilder.addNetworkInterceptor(networkInterceptor);
    }
    return okHttpBuilder.build();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) AuthenticationInterceptor(com.example.networking.AuthenticationInterceptor) Interceptor(okhttp3.Interceptor) AuthenticationInterceptor(com.example.networking.AuthenticationInterceptor) BaseUrlInterceptor(com.example.networking.BaseUrlInterceptor) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 25 with Provides

use of dagger.Provides in project kickmaterial by byoutline.

the class GlobalModule method providesLoginManager.

@Provides
@GlobalScope
public LoginManager providesLoginManager(Bus bus, KickMaterialService service, AccessTokenProvider accessTokenProvider) {
    LoginManager instance = new LoginManager(service, accessTokenProvider);
    bus.register(instance);
    return instance;
}
Also used : LoginManager(com.byoutline.kickmaterial.managers.LoginManager) Provides(dagger.Provides)

Aggregations

Provides (dagger.Provides)46 Singleton (javax.inject.Singleton)35 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)11 OkHttpClient (okhttp3.OkHttpClient)10 OkHttpClient (com.squareup.okhttp.OkHttpClient)5 StethoInterceptor (com.facebook.stetho.okhttp3.StethoInterceptor)3 GsonBuilder (com.google.gson.GsonBuilder)3 Cache (okhttp3.Cache)3 LoginManager (com.byoutline.kickmaterial.managers.LoginManager)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 PlaceRenderer (com.github.pedrovgs.sample.renderer.PlaceRenderer)2 TvShowRenderer (com.github.pedrovgs.sample.renderer.TvShowRenderer)2 Gson (com.google.gson.Gson)2 BindingsGroup (dagger.internal.BindingsGroup)2 SetBinding (dagger.internal.SetBinding)2 PerApplication (io.hefuyi.listener.injector.scope.PerApplication)2 File (java.io.File)2 LinkedHashMap (java.util.LinkedHashMap)2 Named (javax.inject.Named)2 ExecutableElement (javax.lang.model.element.ExecutableElement)2