当前位置: 首页>>代码示例>>Java>>正文


Java GsonConverterFactory.create方法代码示例

本文整理汇总了Java中retrofit2.converter.gson.GsonConverterFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Java GsonConverterFactory.create方法的具体用法?Java GsonConverterFactory.create怎么用?Java GsonConverterFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在retrofit2.converter.gson.GsonConverterFactory的用法示例。


在下文中一共展示了GsonConverterFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildGsonConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
/**
 * 构建GSON转换器
 * @return GsonConverterFactory
 */
private static GsonConverterFactory buildGsonConverterFactory(){
    GsonBuilder builder = new GsonBuilder();
    builder.setLenient();

    // 注册类型转换适配器
    builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
        @Override
        public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
            return null == json ? null : new Date(json.getAsLong());
        }
    });

    Gson gson = builder.create();
    return GsonConverterFactory.create(gson);
}
 
开发者ID:qiaop,项目名称:basicapp,代码行数:20,代码来源:RetrofitHelper.java

示例2: setupApiServices

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
private void setupApiServices(String streamingUrl, String recordingUrl) {
	OkHttpClient client = new OkHttpClient();
	GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create();
	RxJava2CallAdapterFactory rxJava2CallAdapterFactory = RxJava2CallAdapterFactory.create();

	Retrofit retrofitRecordings = new Retrofit.Builder()
			.baseUrl(recordingUrl)
			.client(client)
			.addConverterFactory(gsonConverterFactory)
			.addCallAdapterFactory(rxJava2CallAdapterFactory)
			.build();
	mRecordingApiService = retrofitRecordings.create(RecordingService.class);

	Retrofit retrofigStreaming = new Retrofit.Builder()
			.baseUrl(streamingUrl)
			.client(client)
			.addConverterFactory(gsonConverterFactory)
			.addCallAdapterFactory(rxJava2CallAdapterFactory)
			.build();
	mStreamingApiService = retrofigStreaming.create(StreamingService.class);
}
 
开发者ID:NiciDieNase,项目名称:chaosflix,代码行数:22,代码来源:MediaApiService.java

示例3: YelpV3APIProvider

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
public YelpV3APIProvider(String client_id, String client_secret) {
   httpClient = new OkHttpClient.Builder()
         .connectTimeout(10, TimeUnit.SECONDS)
         .readTimeout(15, TimeUnit.SECONDS)
         .writeTimeout(15, TimeUnit.SECONDS)
         .build();

   gsonConverterFactory = GsonConverterFactory.create();

   yelpAuth = new Retrofit.Builder()
         .baseUrl(API_HOST)
         .addConverterFactory(gsonConverterFactory)
         .client(httpClient)
         .build()
         .create(YelpOAuth2.class);

   this.client_id = client_id;
   this.client_secret = client_secret;
}
 
开发者ID:nickwu241,项目名称:android-yelp-v3-api,代码行数:20,代码来源:YelpV3APIProvider.java

示例4: createService

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
@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);
}
 
开发者ID:jsaund,项目名称:RxUploader,代码行数:25,代码来源:Service.java

示例5: getInstance

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
public static Retrofit getInstance(){
    if (retrofit == null) {
        OkHttpClient okHttpClient = new OkHttpClient();
        OkHttpClient.Builder builder = okHttpClient.newBuilder();
        builder.retryOnConnectionFailure(true);
        GsonConverterFactory factory = GsonConverterFactory.create();
        retrofit = new Retrofit.Builder().client(okHttpClient)
                .baseUrl(Constants.BASE_URL)
                .addConverterFactory(factory)
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
    }
    return retrofit;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:15,代码来源:ApiClient.java

示例6: create

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
public Retrofit create(final Class<?> clazz) {

        final retrofit2.Converter.Factory factory = GsonConverterFactory.create(gson);
        final OkHttpClient client = httpFactory.create(clazz);

        return new Retrofit.Builder()
                .baseUrl(this.baseUrl)
                .client(client)
                .addConverterFactory(factory)
                .build();
    }
 
开发者ID:MikeFot,项目名称:Java--Steam-Loader,代码行数:12,代码来源:Retrofit2Factory.java

示例7: gsonConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
@MyAppComponentScope
@Provides
public GsonConverterFactory gsonConverterFactory(){
    return GsonConverterFactory.create();
}
 
开发者ID:01sadra,项目名称:Detoxiom,代码行数:6,代码来源:NetworkModule.java

示例8: provideConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
@Provides
@Singleton
public Converter.Factory provideConverterFactory(Gson gson) {
	return GsonConverterFactory.create(gson);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:RetrofitModule.java

示例9: GsonCustomConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
private GsonCustomConverterFactory(Gson gson) {
  if (gson == null)
    throw new NullPointerException("gson == null");
  this.gson = gson;
  this.gsonConverterFactory = GsonConverterFactory.create(gson);
}
 
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:7,代码来源:ApiClient.java

示例10: provideGsonConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
@Singleton
@Provides
GsonConverterFactory provideGsonConverterFactory() {
    return GsonConverterFactory.create();
}
 
开发者ID:metao1,项目名称:Dagger2-Retrofit-MVP-OKHttp3-ButterKnife-Glide-Example,代码行数:6,代码来源:ApplicationModule.java

示例11: providesConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
@Provides
@Singleton
public Converter.Factory providesConverterFactory() {
    return GsonConverterFactory.create();
}
 
开发者ID:raulh82vlc,项目名称:Avengers,代码行数:6,代码来源:ComicsRepositoryModule.java

示例12: provideGsonConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
@Provides
@Singleton
Converter.Factory provideGsonConverterFactory() {
  return GsonConverterFactory.create();
}
 
开发者ID:quangctkm9207,项目名称:mvp-android-arch-component,代码行数:6,代码来源:ApiServiceModule.java

示例13: provideGsonConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
@Provides
@Singleton
public Converter.Factory provideGsonConverterFactory(Gson gson) {
    return GsonConverterFactory.create(gson);
}
 
开发者ID:mirhoseini,项目名称:bcg,代码行数:6,代码来源:ApiModule.java

示例14: provideConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
@Provides
@Singleton
public Converter.Factory provideConverterFactory() {
    return GsonConverterFactory.create();
}
 
开发者ID:oantajames,项目名称:mdb-android-application,代码行数:6,代码来源:NetworkModule.java

示例15: provideGsonConverterFactory

import retrofit2.converter.gson.GsonConverterFactory; //导入方法依赖的package包/类
@Provides
@Singleton
Converter.Factory provideGsonConverterFactory() {
    return GsonConverterFactory.create();
}
 
开发者ID:n1rocket,项目名称:eggs-android,代码行数:6,代码来源:ClientModule.java


注:本文中的retrofit2.converter.gson.GsonConverterFactory.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。