@Provides @Singleton public ApiService apiService(DemoConfig demoConfig) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return new Retrofit.Builder() .baseUrl(demoConfig.getApiUrl()) .addConverterFactory(JacksonConverterFactory.create(mapper)).build() .create(ApiService.class); } }
public static AppService getApiService() { return retrofit.create(AppService.class); }
public RetrofitRestRepository(Retrofit retrofit) { apiService = retrofit.create(ApiService.class); }
public Authenticator(Context context) { super(context); this.context = context; this.app = (GithubApplication) context.getApplicationContext(); this.retrofit = RetrofitUtil.getRetrofitWithoutTokenInstance(context); this.service = retrofit.create(GithubService.class); }
public TokenInteractorImpl(Context context, final OnTokenCreatedListener listener){ this.context = context; this.listener = listener; this.service = RetrofitUtil.getRetrofitWithoutTokenInstance(context).create(GithubService.class); }
@Provides @UserScope public GitHubApiInterface providesGitHubInterface(Retrofit retrofit) { return retrofit.create(GitHubApiInterface.class); } }
public RepoInteractorImpl(Context context, final OnLoadRepoListener listener){ this.context = context; this.listener = listener; this.service = RetrofitUtil.getJsonRetrofitInstance(context).create(GithubService.class); this.gitHubAccount = GitHubAccount.getInstance(context); }
public FindItemsInteractorImpl(Context context, final OnLoadItemListListener listener) { this.context = context; this.service = RetrofitUtil.getJsonRetrofitInstance(context).create(GithubService.class); this.gitHubAccount = GitHubAccount.getInstance(context); this.listener = listener; }
public RepoAndEventPreviewInteractorImpl(final Context context, final OnLoadRepoAndEventPreviewListener listener){ this.context = context; this.listener = listener; this.service = RetrofitUtil.getJsonRetrofitInstance(context).create(GithubService.class); this.gitHubAccount = GitHubAccount.getInstance(context); }
public CodeInteractorImpl(final Context context, final OnCodeListener listener){ this.listener = listener; this.context = context; this.service = RetrofitUtil.getStringRetrofitInstance(context).create(GithubService.class); this.gitHubAccount = GitHubAccount.getInstance(context); }
@Override public void onCreate() { super.onCreate(); sInstance = this; mEngine = new Retrofit.Builder() .baseUrl("http://7xk9dj.com1.z0.glb.clouddn.com/") .addConverterFactory(GsonConverterFactory.create()) .build().create(Engine.class); }
@Inject public GitLabService(@NonNull GitLabConfiguration gitLabConfiguration) { this.gitLabConfiguration = gitLabConfiguration; this.gitLabEndPoints = new Retrofit.Builder() .baseUrl(sanitizeURL(gitLabConfiguration.getUrl())) .addConverterFactory(JacksonConverterFactory.create()) .build() .create(GitLabEndPoints.class); }
@Provides @Singleton protected GitHubService provideGitHubService() { Retrofit retrofit = new Retrofit.Builder() .baseUrl(GitHubService.ENDPOINT) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) // 添加Rx适配器 .addConverterFactory(GsonConverterFactory.create()) // 添加Gson转换器 .build(); return retrofit.create(GitHubService.class); } }
public Model() { mDatabase = new Database(); Gson gson = new GsonBuilder() .registerTypeAdapter(Date.class, new DateDeserializer()) .registerTypeAdapter(new TypeToken<RealmList<Video>>() {}.getType(), new VideoRealmListDeserializer()) .registerTypeAdapter(new TypeToken<RealmList<Review>>() {}.getType(), new ReviewRealmListDeserializer()) .setExclusionStrategies(new RealmExclusionStrategy()) .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .create(); Retrofit retrofit = new Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create(gson)) .build(); mApiService = retrofit.create(MovieDBApiService.class); mApiKey = "075c3ac2845f0a71e38797ec6f57cdfb"; getDataBus().register(this); }
public GcmServerService() { this.apiGcmServer = new Retrofit.Builder() .baseUrl(ApiGcmServer.URL_BASE) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .build().create(ApiGcmServer.class); }
public GitHubClient() { mGitHubService = new Retrofit.Builder() .baseUrl(GitHubService.BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build() .create(GitHubService.class); }
public GitHubClient() { mClient = new Retrofit.Builder() .baseUrl("https://api.github.com") .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build() .create(GitHubService.class); }
private void downloadImages() { mWebServiceProxy = new Retrofit.Builder().baseUrl(WebServiceProxy.ENDPOINT) .addConverterFactory(GsonConverterFactory.create()) .build().create(WebServiceProxy.class); Call<ResponseData> call = mWebServiceProxy.getImages(); call.enqueue(this); }
public static <T> T createApi(Context context, Class<T> clazz) { if (singleton == null) { synchronized (RetrofitUtils.class) { if (singleton == null) { Retrofit.Builder builder = new Retrofit.Builder(); builder.baseUrl("http://zhuanlan.zhihu.com/") .addConverterFactory(GsonConverterFactory.create())//设置远程地址 .addCallAdapterFactory(RxJavaCallAdapterFactory.create()); singleton = builder.build(); } } } return singleton.create(clazz); }
static CassieqApi createClient(String baseUri, CassieqCredentials cassieqCredentials) { final Logger logger = getLogger(CassieqApi.class); OkHttpClient client = new OkHttpClient(); client.interceptors().add(chain -> { final Request request = chain.request(); return chain.proceed(cassieqCredentials.authorize(request)); }); Retrofit retrofit = new Retrofit.Builder() .baseUrl(baseUri) .addConverterFactory(JacksonConverterFactory.create(Mappers.getJson())) .client(client) .build(); return retrofit.create(CassieqApi.class); }