retrofit2.converter.simplexml.SimpleXmlConverterFactory Java Examples

The following examples show how to use retrofit2.converter.simplexml.SimpleXmlConverterFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NewsDataSource.java    From black-mirror with MIT License 5 votes vote down vote up
public NewsDataSource() {
    tvn24Rss = new Retrofit.Builder()
            .baseUrl("https://www.tvn24.pl/")
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .addConverterFactory(SimpleXmlConverterFactory.create())
            .build()
            .create(Tvn24Rss.class);
    polsatNewsRss = new Retrofit.Builder()
            .baseUrl("http://www.polsatnews.pl/rss/")
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .addConverterFactory(SimpleXmlConverterFactory.create())
            .build()
            .create(PolsatNewsRss.class);
}
 
Example #2
Source File: ItHomeRequest.java    From MicroReader with MIT License 5 votes vote down vote up
public static ItHomeApi getItHomeApi() {
    synchronized (monitor) {
        if (itHomeApi == null) {
            itHomeApi = new Retrofit.Builder()
                    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                    .addConverterFactory(SimpleXmlConverterFactory.create())
                    .client(client)
                    .baseUrl("http://api.ithome.com")
                    .build().create(ItHomeApi.class);
        }
        return itHomeApi;
    }
}
 
Example #3
Source File: RundeckClient.java    From rundeck-cli with Apache License 2.0 5 votes vote down vote up
private Client<A> buildRundeckClient() {
    //url without version
    String appBaseUrl = buildBaseAppUrlForVersion(baseUrl);
    final String apiBaseUrl;
    if (null != apiVersion) {
        //construct api url using requested version
        apiBaseUrl = buildApiUrlForVersion(appBaseUrl, apiVersion);
    } else {
        //if url has no version, use default
        apiBaseUrl = buildApiUrlForVersion(baseUrl, API_VERS);
    }
    //detected final version
    int usedApiVers = apiVersionForUrl(apiBaseUrl, API_VERS);

    okhttp.addInterceptor(new StaticHeaderInterceptor("User-Agent", userAgent));


    Retrofit build = new Retrofit.Builder()
            .baseUrl(apiBaseUrl)
            .client(okhttp.build())
            .addConverterFactory(new QualifiedTypeConverterFactory(
                    JacksonConverterFactory.create(),
                    SimpleXmlConverterFactory.create(),
                    true
            ))
            .build();

    return new Client<>(
            build.create(api),
            build,
            appBaseUrl,
            apiBaseUrl,
            usedApiVers,
            allowVersionDowngrade,
            logger
    );
}
 
Example #4
Source File: ApplicationModule.java    From RetrofitSoapSample with Apache License 2.0 5 votes vote down vote up
@Provides
@Singleton
public UsStatesApi providesApi(){

    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();

    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

    Strategy strategy = new AnnotationStrategy();

    Serializer serializer = new Persister(strategy);

    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .addInterceptor(interceptor)
            .connectTimeout(2, TimeUnit.MINUTES)
            .writeTimeout(2, TimeUnit.MINUTES)
            .readTimeout(2, TimeUnit.MINUTES)
            .build();

    Retrofit retrofit =  new Retrofit.Builder()
            .addConverterFactory(SimpleXmlConverterFactory.create(serializer))
            .baseUrl("http://www.webservicex.net/")
            .client(okHttpClient)
            .build();

    return retrofit.create( UsStatesApi.class);

}
 
Example #5
Source File: ApiModule.java    From klingar with Apache License 2.0 5 votes vote down vote up
@Provides @Singleton @Named("plex")
Retrofit providePlexRetrofit(@Named("plex") OkHttpClient client,
                             SimpleXmlConverterFactory simpleXml,
                             RxJava2CallAdapterFactory rxJava) {
  return new Retrofit.Builder()
      .baseUrl(PLEX_URL)
      .callFactory(client)
      .addConverterFactory(simpleXml)
      .addCallAdapterFactory(rxJava)
      .build();
}
 
Example #6
Source File: ApiModule.java    From klingar with Apache License 2.0 5 votes vote down vote up
@Provides @Singleton @Named("media")
Retrofit provideMediaRetrofit(@Named("default") OkHttpClient client,
                              SimpleXmlConverterFactory simpleXml,
                              RxJava2CallAdapterFactory rxJava) {
  return new Retrofit.Builder()
      .baseUrl(PLEX_URL) // never used
      .callFactory(client)
      .addConverterFactory(simpleXml)
      .addCallAdapterFactory(rxJava)
      .build();
}
 
Example #7
Source File: AppModule.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
@Singleton
@Provides
@Named("xml")
Retrofit.Builder provideXmlRetrofit(OkHttpClient client, Gson gson) {
    return new Retrofit.Builder()
            .client(client)
            .addConverterFactory(SimpleXmlConverterFactory.create());
}
 
Example #8
Source File: BaseApiManager.java    From incubator-taverna-mobile with Apache License 2.0 5 votes vote down vote up
/********
 * Helper class that sets up a new services with simplexml converter factory
 *******/

private <T> T createSimpleXMLApi(Class<T> clazz, String ENDPOINT) {

    Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(ENDPOINT)
            .addConverterFactory(SimpleXmlConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .client(new TavernaOkHttpClient().getTavernaOkHttpClient())
            .build();

    return retrofit.create(clazz);
}
 
Example #9
Source File: OkHttpManager.java    From Android-Architecture with Apache License 2.0 4 votes vote down vote up
private Retrofit getRetrofitByXml(String baseUrl) {
    return getRetrofit(baseUrl, SimpleXmlConverterFactory.create());
}
 
Example #10
Source File: ApiModule.java    From klingar with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton SimpleXmlConverterFactory provideSimpleXmlConverterFactory() {
  return SimpleXmlConverterFactory.create(new Persister(new Format(new HyphenStyle())));
}