Java 类retrofit2.adapter.rxjava.RxJavaCallAdapterFactory 实例源码

项目:cnBetaGeek    文件:HttpService.java   
private HttpService() {
    //手动创建一个OkHttpClient并设置超时时间
    OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
    httpClientBuilder.connectTimeout(DEFAULT_TIMEOUT, TimeUnit.SECONDS);

    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    httpClientBuilder.addInterceptor(interceptor).build();

    retrofit = new Retrofit.Builder()
            .client(httpClientBuilder.build())
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .baseUrl(BASE_URL)
            .build();
}
项目:CommonFramework    文件:AbsRetrofit.java   
/**
 * 获取通用配置的Retrofit实例,同时提供数据转换工厂定制,与拦截器定制
 * @param context Application对应的context:getApplicationContext
 * @param baseUrl 服务器接口url通用部分
 * @param converterFactory 定制的数据转换工厂
 * @param interceptor 定制的拦截器
 * @return
 */
protected static Retrofit getRetrofit(
        Context context, String baseUrl, Converter.Factory converterFactory, Interceptor interceptor) {
    if (null == mRetrofit) {
        if (null == mOkHttpClient) {
            mOkHttpClient = OkHttpUtils.getOkHttpClient(context, interceptor);
        }

        Retrofit.Builder builder = new Retrofit.Builder();
        // 设置服务器路径Url通用部分
        builder.baseUrl(baseUrl);
        // 添加数据转换工厂,支持自定义数据转换工厂,默认使用Gson
        if (converterFactory != null) {
            builder.addConverterFactory(converterFactory);
        } else {
            builder.addConverterFactory(GsonConverterFactory.create());
        }
        // 添加回调工厂,采用RxJava
        builder.addCallAdapterFactory(RxJavaCallAdapterFactory.create());
        // 设置使用OkHttp网络请求库
        builder.client(mOkHttpClient);
        mRetrofit = builder.build();
    }

    return mRetrofit;
}
项目:GitHubRxJava    文件:ServiceFactory.java   
public static <T> T createRetrofitService(final Class<T> clazz, final String endPoint) {
    // Logs
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

    final Retrofit restAdapter = new Retrofit.Builder()
            .baseUrl(endPoint)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())
            .client(new OkHttpClient.Builder()
                    .addInterceptor(interceptor)
                    .build())
            .build();

    return restAdapter.create(clazz);
}
项目:xifan    文件:HttpRequestFactory.java   
public HttpRequestFactory() {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.HEADERS);

    OkHttpClient okHttpClient =
            new OkHttpClient.Builder().connectTimeout(TIMEOUT, TimeUnit.SECONDS)
                    .readTimeout(TIMEOUT, TimeUnit.SECONDS)
                    .writeTimeout(TIMEOUT, TimeUnit.SECONDS)
                    .cache(getCache())
                    .addInterceptor(logging)
                    .addNetworkInterceptor(mTokenInterceptor)
                    //应用拦截器,用于离线缓存
                    .addInterceptor(mCacheInterceptor)
                    //网络拦截器,用于在线缓存
                    .addNetworkInterceptor(mCacheInterceptor)
                    .addNetworkInterceptor(new StethoInterceptor())
                    .build();

    Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.FanFou.FANFOU_API_URL)
            .addConverterFactory(ResponseConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .client(okHttpClient)
            .build();

    mServiceFactory = retrofit.create(ApiFactory.class);
}
项目:GCSApp    文件:AppClient2.java   
public static Retrofit retrofit() {
    if (mRetrofit == null) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();

        if (BuildConfig.DEBUG) {
            // Log信息拦截器
            HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            //设置 Debug Log 模式
            builder.addInterceptor(loggingInterceptor);
        }
        OkHttpClient okHttpClient = builder.build();
        mRetrofit = new Retrofit.Builder()
                .baseUrl(ApiStores2.URL_BASE)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .client(okHttpClient)
                .build();
    }
    return mRetrofit;
}
项目:GitHub    文件:ApiModule.java   
@Provides Retrofit retrofit() {
  OkHttpClient client = new OkHttpClient.Builder()
      .addInterceptor(new Interceptor() {
        @Override
        public Response intercept(Chain chain) throws IOException {
          return chain.proceed(
              chain.request()
                  .newBuilder()
                  .addHeader("Authorization", "Client-ID " + ImgurService.CLIENT_ID)
                  .build());
        }
      })
      .build();
  return new Retrofit.Builder()
      .client(client)
      .addConverterFactory(GsonConverterFactory.create())
      .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
      .baseUrl("https://api.imgur.com/3/")
      .build();
}
项目:newIPlay    文件:ApiManager.java   
private ApiManager() {

        /**
         * 设置请求超时时间为5秒
         */
        mOkHttpClient = new OkHttpClient.Builder()
                .connectTimeout(5000, TimeUnit.MILLISECONDS)
                .readTimeout(5000, TimeUnit.MILLISECONDS)
                .writeTimeout(5000, TimeUnit.MILLISECONDS).build();

        //.addConverterFactory(fastJsonConverterFactory)
        mRetrofit = new Retrofit.Builder()
                .client(mOkHttpClient)
                .baseUrl("https://i.play.163.com/")
                .addConverterFactory(GsonConverterFactory.create())
                //.addConverterFactory(fastJsonConverterFactory)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
    }
项目:RxUploader    文件:Service.java   
@NonNull
private static <S> S createService(@NonNull Class<S> s, @NonNull String token,
        @NonNull String secret) {
    final GsonConverterFactory serializer = GsonConverterFactory.create(
            new GsonBuilder().registerTypeAdapterFactory(JSONModelTypeAdapterFactory.create())
                    .create());

    final OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
    OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(
            Config.CONSUMER_KEY, Config.CONSUMER_SECRET);
    consumer.setTokenWithSecret(token, secret);
    httpClient.addInterceptor(new SigningInterceptor(consumer));

    final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(Config.HTTP_LOG_LEVEL);
    httpClient.addInterceptor(loggingInterceptor);

    final Retrofit client = new Retrofit.Builder().baseUrl(Config.HOST)
            .addConverterFactory(serializer)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .client(httpClient.build())
            .build();
    return client.create(s);
}
项目:TWStreaming    文件:NetworkModule.java   
@Provides
@Singleton
Retrofit provideCall() {
    OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(App.getTwitterKey(),
            App.getTwitterSecret());
    consumer.setTokenWithSecret(
            App.getApplicationInstance().getTwitterSession().getAuthToken().token,
            App.getApplicationInstance().getTwitterSession().getAuthToken().secret);

    Retrofit.Builder builder =
            new Retrofit.Builder()
                    .baseUrl(baseUrl)
                    .addConverterFactory(GsonConverterFactory.create())
                    .addConverterFactory(ScalarsConverterFactory.create())
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create());

    OkHttpClient client = new OkHttpClient.Builder()
            .addInterceptor(new SigningInterceptor(consumer))
            .addNetworkInterceptor(new StethoInterceptor())
            .build();

    return builder.client(client).build();
}
项目:in-store-api-java-sdk    文件:ProtoCoreProvider.java   
default ProtoCore getProtocore() {
    Gson gson = NetworkUtilities.getGson();
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(getSatispayContext().getBaseUrl())
            .addConverterFactory(GsonConverterFactory.create(gson))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .client(
                    getProtocoreHttpClientProvider().getProtocoreClient(
                            getSatispayContext(),
                            getSecurePersistenceManager(),
                            getSessionManager(),
                            getSdkDeviceInfo()
                    )
            )
            .build();
    return retrofit.create(ProtoCore.class);
}
项目:Retrofit2Demo    文件:Example1Activity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_example);

    mTv= (TextView) findViewById(R.id.tv);

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl("https://api.github.com/")
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .client(new OkHttpClient())
            .build();

    GitHubService service=retrofit.create(GitHubService.class);

    service.contributors1("square", "retrofit")
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(s-> mTv.setText(s.toString()));
}
项目:jira-steps-plugin    文件:JiraService.java   
public JiraService(final Site jiraSite) {
  this.jiraSite = jiraSite;

  final ConnectionPool CONNECTION_POOL = new ConnectionPool(5, 60, TimeUnit.SECONDS);

  OkHttpClient httpClient = new OkHttpClient.Builder()
      .connectTimeout(jiraSite.getTimeout(), TimeUnit.MILLISECONDS)
      .readTimeout(10000, TimeUnit.MILLISECONDS).connectionPool(CONNECTION_POOL)
      .retryOnConnectionFailure(true).addInterceptor(new SigningInterceptor(jiraSite)).build();

  final ObjectMapper mapper = new ObjectMapper();
  mapper.registerModule(new JodaModule());
  this.jiraEndPoints = new Retrofit.Builder().baseUrl(this.jiraSite.getUrl().toString())
      .addConverterFactory(JacksonConverterFactory.create(mapper))
      .addCallAdapterFactory(RxJavaCallAdapterFactory.create()).client(httpClient).build()
      .create(JiraEndPoints.class);
}
项目:TestChat    文件:HttpDownLoadManager.java   
public void start(final DownInfo info) {
//                如果消息实体为空,或正在下载,则返回
                if (info == null || mDownInfoMap.get(info.getUrl()) != null) return;
                DownLoadSubscriber<DownInfo> downLoadSubscriber = new DownLoadSubscriber<>(info);
                mDownInfoMap.put(info.getUrl(), downLoadSubscriber);
//                HttpService service;
//                增加一个拦截器,用于获取数据的进度回调
                DownLoadInterceptor interceptor = new DownLoadInterceptor(downLoadSubscriber);
                OkHttpClient.Builder builder = new OkHttpClient.Builder();
                builder.connectTimeout(info.getConnectedTime(), TimeUnit.SECONDS).addInterceptor(interceptor);
                Retrofit retrofit = new Retrofit.Builder().
                        addConverterFactory(ScalarsConverterFactory.create()).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).
                        baseUrl(CommonUtils.getBaseUrl(info.getUrl())).client(builder.build()).build();
                HttpService service = retrofit.create(HttpService.class);
                info.setHttpService(service);
                service.download("bytes=" + info.getReadLength() + "-", info.getUrl()).subscribeOn(Schedulers.io())
                        .unsubscribeOn(Schedulers.io()).retryWhen(new RetryWhenNetWorkException()).map(new Func1<ResponseBody, DownInfo>() {
                        @Override
                        public DownInfo call(ResponseBody responseBody) {
                                FileUtil.writeToCache(responseBody, info.getSavedFilePath(), info.getReadLength(), info.getTotalLength());
//                                这里进行转化
                                return info;
                        }
                }).observeOn(AndroidSchedulers.mainThread()).subscribe(downLoadSubscriber);
        }
项目:google-speech-api-android    文件:GoogleSpeechServiceFactory.java   
@NonNull
public static GoogleSpeechService newService() {
    return new GoogleSpeechServiceImpl(
            new Retrofit.Builder()
                    .baseUrl(HOST_SPEECH_API)
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .addConverterFactory(new GoogleSpeechServiceConverterFactory())
                    .build()
                    .create(SpeechApi.class),
            new Retrofit.Builder()
                    .baseUrl(HOST_SUPPORTED_LANGUAGE_API)
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .addConverterFactory(new GoogleSpeechServiceConverterFactory())
                    .build()
                    .create(SupportedLanguageApi.class),
            new AuthenticationSpeechApiBridgeCache()
    );
}
项目:lqrwechatrongcloud    文件:ApiRetrofit.java   
private ApiRetrofit() {
    super();
    //创建一个Gson对象
    Gson gson = new GsonBuilder()
            .setLenient()
            .create();

    //在构造方法中完成对Retrofit接口的初始化 创建 Retrofit对象
    mApi = new Retrofit.Builder()
            .baseUrl(MyApi.BASE_URL)
            .client(getClient())
            .addConverterFactory(GsonConverterFactory.create(gson))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build()
            .create(MyApi.class);
}
项目:retrofit-metrics    文件:TimedCallAdapterFactoryTest.java   
@Before
public void before() throws IOException {
    metrics = new MetricRegistry();
    server = new MockWebServer();
    server.start();

    MockResponse response = new MockResponse();
    response.setBody(RESPONSE_BODY);
    server.enqueue(response);

    retrofit = new Retrofit.Builder()
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(new TimedCallAdapterFactory(metrics))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .baseUrl(server.url("/").toString())
            .build();
}
项目:GCSApp    文件:AppClient.java   
public static Retrofit retrofit() {
    if (mRetrofit == null) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        if (BuildConfig.DEBUG) {
            // Log信息拦截器
            HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
            loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            //设置 Debug Log 模式
            builder.addInterceptor(loggingInterceptor);
        }
        OkHttpClient okHttpClient = builder.build();
        mRetrofit = new Retrofit.Builder()
                .baseUrl(ApiStores.URL_BASE)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .client(okHttpClient)
                .build();
    }
    return mRetrofit;
}
项目:memory-game    文件:ServiceUtils.java   
public static Retrofit createDefaultRetrofitBuilder(String baseUrl, boolean useSsl, Gson gson, Interceptor... interceptors) {

        OkHttpClient.Builder okHttpClientBuilder = createDefaultClient(useSsl);
        if (interceptors != null && interceptors.length > 0) {
            for (Interceptor interceptor : interceptors) {
                okHttpClientBuilder.interceptors().add(interceptor);
            }
        }

        return new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .client(okHttpClientBuilder.build())
                .build();
    }
项目:Paper-Melody    文件:RetrofitClient.java   
public static SocialSystemAPI getSocialSystemAPI() {
    if (socialSystemAPI == null) {
        Executor executor = Executors.newCachedThreadPool();
        final Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new GsonDateTypeAdapter()).create();

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .callbackExecutor(executor)
                .addConverterFactory(GsonConverterFactory.create(gson))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .client(OkHttpProvider.getInstance())
                .build();

        socialSystemAPI = retrofit.create(SocialSystemAPI.class);
    }
    return socialSystemAPI;
}
项目:tubik    文件:APIYouTubeTest.java   
@Before
public void setUp() {
    OkHttpClient.Builder builder = new OkHttpClient.Builder()
            .addInterceptor(youtubeInterceptor)
            .addInterceptor(provideHttpLoggingInterceptor())
            .connectTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
            .readTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
            .writeTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
            .cache(cache);

    OkHttpClient httpClient = builder.build();

    retrofit = new Retrofit.Builder()
            .baseUrl(APIYouTube.URL)
            .client(httpClient)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();

    mApi = retrofit.create(APIYouTube.class);
}
项目:tubik    文件:APILastFMTest.java   
@Before
public void setUp() {
    OkHttpClient.Builder builder = new OkHttpClient.Builder()
            .addInterceptor(new LastFMKeyInterceptor())
            .addInterceptor(provideHttpLoggingInterceptor())
            .addNetworkInterceptor(new CacheInterceptor())
            .connectTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
            .readTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
            .writeTimeout(CONNECTION_TIMEOUT, TimeUnit.SECONDS)
            .cache(cache);

    OkHttpClient httpClient = builder.build();

    retrofit = new Retrofit.Builder()
            .baseUrl(APILastFM.URL)
            .client(httpClient)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            //.addCallAdapterFactory(RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io()))
            .build();

    mApi = retrofit.create(APILastFM.class);
}
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:NetworkUtil.java   
public static RetrofitInterface getRetrofit(String email, String password) {

        String credentials = email + ":" + password;
        String basic = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

        httpClient.addInterceptor(chain -> {

            Request original = chain.request();
            Request.Builder builder = original.newBuilder()
                    .addHeader("Authorization", basic)
                    .method(original.method(),original.body());
            return  chain.proceed(builder.build());

        });

        RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());

        return new Retrofit.Builder()
                .baseUrl(Constants.BASE_URL)
                .client(httpClient.build())
                .addCallAdapterFactory(rxAdapter)
                .addConverterFactory(GsonConverterFactory.create())
                .build().create(RetrofitInterface.class);
    }
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:NetworkUtil.java   
public static RetrofitInterface getRetrofit(String token) {

        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

        httpClient.addInterceptor(chain -> {

            Request original = chain.request();
            Request.Builder builder = original.newBuilder()
                    .addHeader("x-access-token", token)
                    .method(original.method(),original.body());
            return  chain.proceed(builder.build());

        });

        RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());

        return new Retrofit.Builder()
                .baseUrl(Constants.BASE_URL)
                .client(httpClient.build())
                .addCallAdapterFactory(rxAdapter)
                .addConverterFactory(GsonConverterFactory.create())
                .build().create(RetrofitInterface.class);
    }
项目:RLibrary    文件:RRetrofit.java   
public static <T> T create(final Class<T> cls, CacheType cacheType, String baseUrl) {
        Converter.Factory factory = getFactory();

        Retrofit.Builder builder = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .client(defaultClient(cacheType))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create());

        if (factory != null) {
            builder.addConverterFactory(factory);
        }

//        builder.addConverterFactory(ScalarsConverterFactory.create());

        try {
            saveToSDCard(cls.getSimpleName());
        } catch (Exception e) {
            e.printStackTrace();
        }

        Retrofit retrofit = builder.build();
        return retrofit.create(cls);
    }
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:NetworkUtil.java   
public static RetrofitInterface getRetrofit(String email, String password) {

        String credentials = email + ":" + password;
        String basic = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

        httpClient.addInterceptor(chain -> {

            Request original = chain.request();
            Request.Builder builder = original.newBuilder()
                    .addHeader("Authorization", basic)
                    .method(original.method(),original.body());
            return  chain.proceed(builder.build());

        });

        RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());

        return new Retrofit.Builder()
                .baseUrl(Constants.BASE_URL)
                .client(httpClient.build())
                .addCallAdapterFactory(rxAdapter)
                .addConverterFactory(GsonConverterFactory.create())
                .build().create(RetrofitInterface.class);
    }
项目:Sistema-de-Comercializacion-Negocios-Jhordan    文件:NetworkUtil.java   
public static RetrofitInterface getRetrofit(String email, String password) {

        String credentials = email + ":" + password;
        String basic = "Basic " + Base64.encodeToString(credentials.getBytes(),Base64.NO_WRAP);
        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

        httpClient.addInterceptor(chain -> {

            Request original = chain.request();
            Request.Builder builder = original.newBuilder()
                    .addHeader("Authorization", basic)
                    .method(original.method(),original.body());
            return  chain.proceed(builder.build());

        });

        RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());

        return new Retrofit.Builder()
                .baseUrl(Constants.BASE_URL)
                .client(httpClient.build())
                .addCallAdapterFactory(rxAdapter)
                .addConverterFactory(GsonConverterFactory.create())
                .build().create(RetrofitInterface.class);
    }
项目:speedr    文件:LimitFetcher.java   
private void buildHereMapsService() {
    Gson gson = new GsonBuilder().create();

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl("https://route.api.here.com/routing/7.2/")
            .addConverterFactory(GsonConverterFactory.create(gson))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();

    hereMapsService = retrofit.create(HereMapsService.class);
    hereMapsErrorConverter = retrofit.responseBodyConverter(HereMapsResponse.class, new Annotation[0]);
}
项目:ClouldReader    文件:HttpUtils.java   
private Retrofit.Builder getBuilder(String apiUrl) {
    Retrofit.Builder builder = new Retrofit.Builder();
    builder.client(getOkClient());
    builder.baseUrl(apiUrl);//设置远程地址
    builder.addConverterFactory(new NullOnEmptyConverterFactory());
    builder.addConverterFactory(GsonConverterFactory.create(getGson()));
    builder.addCallAdapterFactory(RxJavaCallAdapterFactory.create());
    return builder;
}
项目:Unofficial-Ups    文件:UpcServiceFactory.java   
public static <T> T createRetrofitService(final Class<T> clazz){
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(BuildConfig.DEBUG ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE);
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

    Retrofit retrofit = new Retrofit.Builder()
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())
            .client(client)
            .baseUrl(BuildConfig.REST_URL)
            .build();

    return retrofit.create(clazz);

}
项目:Impala    文件:ApiModule.java   
@Provides
@Singleton
Retrofit provideRetrofit(OkHttpClient client,
                         @Named("LOGIN_URL") String url) {
    return new Retrofit.Builder().baseUrl(url)
            .client(client)
            .addConverterFactory(GsonConverterFactory.create(
                    new GsonBuilder().registerTypeAdapterFactory(ImpalaGsonTypeAdapter.create())
                            .create()))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();
}
项目:GitHub    文件:HttpUtils.java   
private Retrofit.Builder getBuilder(String apiUrl) {
    Retrofit.Builder builder = new Retrofit.Builder();
    builder.client(getOkClient());
    builder.baseUrl(apiUrl);//设置远程地址
    builder.addConverterFactory(new NullOnEmptyConverterFactory());
    builder.addConverterFactory(GsonConverterFactory.create(getGson()));
    builder.addCallAdapterFactory(RxJavaCallAdapterFactory.create());
    return builder;
}
项目:GitHub    文件:BookApi.java   
public BookApi(OkHttpClient okHttpClient) {
    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(Constant.API_BASE_URL)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) // 添加Rx适配器
            .addConverterFactory(GsonConverterFactory.create()) // 添加Gson转换器
            .client(okHttpClient)
            .build();
    service = retrofit.create(BookApiService.class);
}
项目:DailyStudy    文件:RetrofitUtil.java   
public static Retrofit retrofit(){
    if (mRetrofit == null){
        initClient();
        mRetrofit = new Retrofit.Builder()
                .baseUrl(ApiStores.API_SERVER_URL)
                .client(mOkHttpClient)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
    }
    return mRetrofit;
}
项目:Huahui-Android    文件:RetrofitManager.java   
private RetrofitManager() {
    retrofit = new Retrofit.Builder()
            .baseUrl("http://liyuyu.cn")
            .client(getNewClient())
            .addConverterFactory(GsonConverterFactory.create(GsonUtil.getGson()))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();
}
项目:KingTV    文件:AppModule.java   
@Provides
 @Singleton
public Retrofit provideRetrofit() {
     return new Retrofit.Builder()
             .baseUrl(baseUrl)
             .addConverterFactory(GsonConverterFactory.create())
             .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
             .client(provideOkHttpClient())
             .build();
 }
项目:LQRWeChat-master    文件:ApiRetrofit.java   
private ApiRetrofit() {
    super();
    Gson gson = new GsonBuilder()
            .setLenient()
            .create();

    //在构造方法中完成对Retrofit接口的初始化
    mApi = new Retrofit.Builder()
            .baseUrl(MyApi.BASE_URL)
            .client(getClient())
            .addConverterFactory(GsonConverterFactory.create(gson))
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build()
            .create(MyApi.class);
}
项目:MeiLa_GNN    文件:RetroManager.java   
/**
 *
 */
public void initRetrofit() {
    if (retrofit == null) {
        retrofit = new Retrofit.Builder()
                .client(client)
                .baseUrl(ApiService.BASE_URL)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create(getGson()))
                .build();
    }

}
项目:INFOotball    文件:NetworkModule.java   
@Provides
@Singleton
public ServerAPI provideServerApi(Gson gson,OkHttpClient okHttpClient){
    return new Retrofit.Builder()
                   .addConverterFactory(GsonConverterFactory.create(gson))
                   .baseUrl(BASE_URL)
                   .client(okHttpClient)
                   .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                   .build().create(ServerAPI.class);
}
项目:INFOotball    文件:NetworkModule.java   
@Provides
@Singleton
public NewsAPI provideNewsApi(Gson gson,OkHttpClient okHttpClient){
    return new Retrofit.Builder()
                   .addConverterFactory(GsonConverterFactory.create(gson))
                   .baseUrl(NEWS_URL)
                   .client(okHttpClient)
                   .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                   .build().create(NewsAPI.class);
}
项目:BeautifulGirls    文件:RetrofitSingleton.java   
private void initRetrofit() {
    sRetrofit = new Retrofit.Builder()
            .baseUrl(Constants.BASE_URL)
            .client(sOkHttp)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(ScalarsConverterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())

            .build();
}