Skip to content

Instantly share code, notes, and snippets.

@mohak1712
Created June 18, 2018 11:24
Show Gist options
  • Save mohak1712/46419c92b0784cfffee39b2573565857 to your computer and use it in GitHub Desktop.
Save mohak1712/46419c92b0784cfffee39b2573565857 to your computer and use it in GitHub Desktop.
@Module
public class ApplicationModule {
private Application mApplication;
public ApplicationModule(Application application) {
mApplication = application;
}
@Provides
Application provideApplication() {
return mApplication;
}
@Provides
@ApplicationContext
Context provideContext() {
return mApplication;
}
@Provides
@Singleton
public Retrofit getRetrofit(OkHttpClient client) {
return new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.baseUrl(BuildConfig.BASE_URL)
.build();
}
@Provides
@Singleton
OkHttpClient getOkHttpClient() {
return new WeatherOkhttp().getWeatherOkhttpClient();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment