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


Java Converter类代码示例

本文整理汇总了Java中retrofit.converter.Converter的典型用法代码示例。如果您正苦于以下问题:Java Converter类的具体用法?Java Converter怎么用?Java Converter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: buildRestAdapter

import retrofit.converter.Converter; //导入依赖的package包/类
/**
 * Build RestAdapter for request
 *
 * @param interceptor - {@link Interceptor} for request (optional)
 * @param converter   - {@link Converter} for Request (optional)
 * @return - {@link RestAdapter} used to create {@link PopdeemAPI}
 */
private RestAdapter buildRestAdapter(Interceptor interceptor, Converter converter) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder()
            .readTimeout(30, TimeUnit.SECONDS)
            .connectTimeout(30, TimeUnit.SECONDS)
            .addInterceptor(PD_API_KEY_INTERCEPTOR);

    if (interceptor != null) {
        builder.addInterceptor(interceptor);
    }

    OkHttpClient okHttpClient = builder.build();

    RestAdapter.Builder adapterBuilder = new RestAdapter.Builder()
            .setClient(new Ok3Client(okHttpClient))
            .setEndpoint(PDAPIConfig.PD_API_ENDPOINT)
            .setLogLevel(RestAdapter.LogLevel.FULL);

    if (converter != null) {
        adapterBuilder.setConverter(converter);
    }

    return adapterBuilder.build();
}
 
开发者ID:Popdeem,项目名称:Popdeem-SDK-Android,代码行数:31,代码来源:PDAPIClient.java

示例2: buildRestAdapter

import retrofit.converter.Converter; //导入依赖的package包/类
/**
 * Build RestAdapter for request
 *
 * @param converter - {@link Converter} for Request (optional)
 * @return - {@link RestAdapter} used to create {@link PDAbraAPI}
 */
private RestAdapter buildRestAdapter(Converter converter) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder()
            .readTimeout(30, TimeUnit.SECONDS)
            .connectTimeout(30, TimeUnit.SECONDS)
            .addInterceptor(PD_API_KEY_INTERCEPTOR);

    Interceptor userInterceptor = getUserIdInterceptor();
    if (userInterceptor != null) {
        builder.addInterceptor(userInterceptor);
    }

    OkHttpClient okHttpClient = builder.build();
    RestAdapter.Builder adapterBuilder = new RestAdapter.Builder()
            .setClient(new Ok3Client(okHttpClient))
            .setEndpoint(PDAbraConfig.ABRA_URL)
            .setLogLevel(RestAdapter.LogLevel.FULL);

    if (converter != null) {
        adapterBuilder.setConverter(converter);
    }

    return adapterBuilder.build();
}
 
开发者ID:Popdeem,项目名称:Popdeem-SDK-Android,代码行数:30,代码来源:PDAbraAPIClient.java

示例3: RestAdapter

import retrofit.converter.Converter; //导入依赖的package包/类
private RestAdapter(Server server, Client.Provider clientProvider, Executor httpExecutor,
                    Executor callbackExecutor, RequestInterceptor requestInterceptor, Converter converter,
                    Profiler profiler, ErrorHandler errorHandler, Log log, LogLevel logLevel)
{
  this.server = server;
  this.clientProvider = clientProvider;
  this.httpExecutor = httpExecutor;
  if (Platform.HAS_RX_JAVA && httpExecutor != null)
  {
    this.rxSupport = new RxSupport(httpExecutor);
  }
  else
  {
    this.rxSupport = null;
  }
  this.callbackExecutor = callbackExecutor;
  this.requestInterceptor = requestInterceptor;
  this.converter = converter;
  this.profiler = profiler;
  this.errorHandler = errorHandler;
  this.log = log;
  this.logLevel = logLevel;
}
 
开发者ID:toadzky,项目名称:retrofit-jaxrs,代码行数:24,代码来源:RestAdapter.java

示例4: getResponseDataConverter

import retrofit.converter.Converter; //导入依赖的package包/类
/**
 * Returns a {@link Converter} configured to deserialize Robin entities.
 *
 * @return A converter.
 */
protected Converter getResponseDataConverter() {
    Gson gson = new GsonBuilder()

            // Set our naming policy to transform underscores <-> camelCase
            .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
            .registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter())
            .registerTypeAdapter(Invitable.class, new InvitableAdapter())
            .registerTypeAdapter(Identifier.class, new IdentifierAdapter())
            .registerTypeAdapterFactory(new RobinTypeAdapterFactory())
            .registerTypeAdapter(Urn.class, new UrnAdapter())
            .registerTypeHierarchyAdapter(Account.Reference.class, new AccountReferenceAdapter())
            .serializeNulls()

            .create();

    return new GsonConverter(gson);
}
 
开发者ID:robinpowered,项目名称:robin-java-sdk,代码行数:23,代码来源:RobinServiceFactory.java

示例5: createConverter

import retrofit.converter.Converter; //导入依赖的package包/类
public static Converter createConverter() {

        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

        return new JacksonConverter(objectMapper);
    }
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:9,代码来源:OauthErrorHandler.java

示例6: createConverter

import retrofit.converter.Converter; //导入依赖的package包/类
@Override
protected Converter createConverter() {

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

    return new JacksonConverter(objectMapper);
}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:10,代码来源:HttpService.java

示例7: provideRetrofit

import retrofit.converter.Converter; //导入依赖的package包/类
@Provides
@Singleton
RestAdapter provideRetrofit(OkHttpClient okHttpClient, Converter converter, ErrorHandler errorHandler)
{
	return new RestAdapter.Builder().setEndpoint(BASE_URL).setClient(new OkClient(okHttpClient)).setConverter(converter).setErrorHandler(errorHandler)
			.setLogLevel(RestAdapter.LogLevel.FULL).build();
}
 
开发者ID:jeksor,项目名称:justweather,代码行数:8,代码来源:NetworkModule.java

示例8: getConverter

import retrofit.converter.Converter; //导入依赖的package包/类
protected Converter getConverter() {
    Gson gson = new GsonBuilder()
            .registerTypeAdapter(Recipe.class, new RecipeDeserializer())
            .registerTypeAdapter(Ingredient.class, new IngredientDeserializer())
            .registerTypeAdapter(Element.class, new ElementDeserializer())
            .create();

    return new GsonConverter(gson);
}
 
开发者ID:dawidgdanski,项目名称:Bakery,代码行数:10,代码来源:GodtCloudImpl.java

示例9: provideAuthRestAdapter

import retrofit.converter.Converter; //导入依赖的package包/类
@Provides @ApplicationScope AuthService provideAuthRestAdapter(Client client, Converter converter) {
    MockRestAdapter mockRestAdapter = MockRestAdapter.from(
            new RestAdapter.Builder().setClient(client).setConverter(converter).setLogLevel(RestAdapter.LogLevel.BASIC).setLog(new RestAdapter.Log() {
                @Override public void log(String message) {
                    Timber.d(message);
                }
            }).setEndpoint("https://alexrwegener.com/").build());
    mockRestAdapter.setDelay(100);
    return mockRestAdapter.create(AuthService.class, new MockAuthService());
}
 
开发者ID:alexrwegener,项目名称:dagger2-scopes,代码行数:11,代码来源:AuthModule.java

示例10: getWeixinTemplateMessageAPI

import retrofit.converter.Converter; //导入依赖的package包/类
static public WeixinTemplateMessageAPI getWeixinTemplateMessageAPI(final Class clazz) {
    final Logger logger = LoggerFactory.getLogger(clazz);
    return new RestAdapter.Builder()
            .setEndpoint("https://api.weixin.qq.com")
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .setLog(new RestAdapter.Log() {
                @Override
                public void log(String message) {
                    logger.info(message);
                }
            })
            .setConverter(new Converter() {
                @Override
                public Object fromBody(TypedInput body, Type type) throws ConversionException {
                    try {
                        return new JSONObject(IOUtils.toString(body.in(), Charsets.UTF_8));
                    } catch (Throwable t) {
                        logger.error("Hit an error!", t);
                        throw new ConversionException(t);
                    }
                }

                @Override
                public TypedOutput toBody(Object object) {
                    TypedOutput typedOutput = new TypedString(object.toString());
                    return typedOutput;
                }
            })
            .build().create(WeixinTemplateMessageAPI.class);
}
 
开发者ID:huahang,项目名称:weixin-utils,代码行数:31,代码来源:WeixinAPIUtils.java

示例11: RetrofitError

import retrofit.converter.Converter; //导入依赖的package包/类
private RetrofitError(String url, Response response, Converter converter, Type successType, boolean networkError, Throwable exception) {
    super(exception);
    this.url = url;
    this.response = response;
    this.converter = converter;
    this.successType = successType;
    this.networkError = networkError;
}
 
开发者ID:goodev,项目名称:android-discourse,代码行数:9,代码来源:RetrofitError.java

示例12: RestAdapter

import retrofit.converter.Converter; //导入依赖的package包/类
private RestAdapter(Server server, Client.Provider clientProvider, Executor httpExecutor, Executor callbackExecutor, RequestInterceptor requestInterceptor, Converter converter, Profiler profiler, ErrorHandler errorHandler, Log log, LogLevel logLevel) {
    this.server = server;
    this.clientProvider = clientProvider;
    this.httpExecutor = httpExecutor;
    this.callbackExecutor = callbackExecutor;
    this.requestInterceptor = requestInterceptor;
    this.converter = converter;
    this.profiler = profiler;
    this.errorHandler = errorHandler;
    this.log = log;
    this.logLevel = logLevel;
}
 
开发者ID:goodev,项目名称:android-discourse,代码行数:13,代码来源:RestAdapter.java

示例13: setConverter

import retrofit.converter.Converter; //导入依赖的package包/类
/**
 * The converter used for serialization and deserialization of objects.
 */
public Builder setConverter(Converter converter) {
    if (converter == null) {
        throw new NullPointerException("Converter may not be null.");
    }
    this.converter = converter;
    return this;
}
 
开发者ID:goodev,项目名称:android-discourse,代码行数:11,代码来源:RestAdapter.java

示例14: getConverter

import retrofit.converter.Converter; //导入依赖的package包/类
public Converter getConverter()
{
  if (mConverter == null)
  {
    mConverter = new CustomJacksonConverter(AutoMapper.getInstance());
  }
  return mConverter;
}
 
开发者ID:offerHere,项目名称:offer,代码行数:9,代码来源:ApiRetrofitExtension.java

示例15: provideRestAdapter

import retrofit.converter.Converter; //导入依赖的package包/类
@Provides @Singleton
RestAdapter provideRestAdapter(Client client, Endpoint endpoint, Converter converter) {
    return new RestAdapter.Builder()
            .setClient(client)
            .setEndpoint(endpoint)
            .setConverter(converter)
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .build();
}
 
开发者ID:blazsolar,项目名称:chuck-norris-jokes-app,代码行数:10,代码来源:ApiModule.java


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