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