Back to project page u2020.
The source code is released under:
Apache License
If you think the Android project u2020 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jakewharton.u2020.data.api; //from w w w . j a v a2 s .c om import android.content.SharedPreferences; import com.jakewharton.u2020.data.ApiEndpoint; import com.jakewharton.u2020.data.IsMockMode; import com.jakewharton.u2020.data.prefs.StringPreference; import dagger.Module; import dagger.Provides; import javax.inject.Singleton; import retrofit.Endpoint; import retrofit.Endpoints; import retrofit.MockRestAdapter; import retrofit.RestAdapter; import retrofit.android.AndroidMockValuePersistence; @Module( complete = false, library = true, overrides = true ) public final class DebugApiModule { @Provides @Singleton Endpoint provideEndpoint(@ApiEndpoint StringPreference apiEndpoint) { return Endpoints.newFixedEndpoint(apiEndpoint.get()); } @Provides @Singleton MockRestAdapter provideMockRestAdapter(RestAdapter restAdapter, SharedPreferences preferences) { MockRestAdapter mockRestAdapter = MockRestAdapter.from(restAdapter); AndroidMockValuePersistence.install(mockRestAdapter, preferences); return mockRestAdapter; } @Provides @Singleton GalleryService provideGalleryService(RestAdapter restAdapter, MockRestAdapter mockRestAdapter, @IsMockMode boolean isMockMode, MockGalleryService mockService) { if (isMockMode) { return mockRestAdapter.create(GalleryService.class, mockService); } return restAdapter.create(GalleryService.class); } }