當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。