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


Java SimpleXmlConverterFactory类代码示例

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


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

示例1: main

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
public static void main(String... args) throws IOException {
  MockWebServer server = new MockWebServer();
  server.start();
  server.enqueue(new MockResponse().setBody("{\"name\": \"Jason\"}"));
  server.enqueue(new MockResponse().setBody("<user name=\"Eximel\"/>"));

  Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(server.url("/"))
      .addConverterFactory(new QualifiedTypeConverterFactory(
          GsonConverterFactory.create(),
          SimpleXmlConverterFactory.create()))
      .build();
  Service service = retrofit.create(Service.class);

  User user1 = service.exampleJson().execute().body();
  System.out.println("User 1: " + user1.name);

  User user2 = service.exampleXml().execute().body();
  System.out.println("User 2: " + user2.name);

  server.shutdown();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:JsonAndXmlConverters.java

示例2: initService

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
private void initService(){
    // Add the interceptor to OkHttpClient
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    OkHttpClient client = builder
            .readTimeout(60, TimeUnit.SECONDS)
            .connectTimeout(60, TimeUnit.SECONDS)
            .build();

    //Google service
    Retrofit retrofitGoogle = new Retrofit.Builder()
            .addConverterFactory(GsonConverterFactory.create())
            .baseUrl(GOOGLE_API_URL)
            .client(client)
            .build();

    mGoogleService = retrofitGoogle.create(IGoogleBookAPI.class);

    //Goodreads service
    Retrofit retrofitGoodReads = new Retrofit.Builder()
            .addConverterFactory(SimpleXmlConverterFactory.create())
            .baseUrl(GOODREADS_API_URL)
            .client(client)
            .build();

    mGoodreadsService = retrofitGoodReads.create(IGoodreadsAPI.class);
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:27,代码来源:APIService.java

示例3: RetrofitApi

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
private RetrofitApi() {

        OkHttpClient okHttpClient = createClient();

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(ApiConstants.API_END_POINT)
                .client(okHttpClient)
                .addConverterFactory(new QualifiedTypeConverterFactory(
                        GsonConverterFactory.create(),
                        SimpleXmlConverterFactory.create()
                ))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();

        buildServices(retrofit);

    }
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:18,代码来源:RetrofitApi.java

示例4: provideRestAdapter

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
@Provides
 @Singleton
 Retrofit provideRestAdapter(Session session) {

  //   LoggingInterceptor interceptor = new LoggingInterceptor(session);
     HttpLoggingInterceptor interceptorHttp = new HttpLoggingInterceptor();
     interceptorHttp.setLevel(HttpLoggingInterceptor.Level.BODY);

     OkHttpClient.Builder builder = new OkHttpClient.Builder();
     builder.connectTimeout(Constants.TIME_OUT_CONNECTION, TimeUnit.SECONDS); // connect timeout

//     builder.interceptors().add(interceptor);
     builder.interceptors().add(interceptorHttp);
     OkHttpClient client = builder.build();

     return new Retrofit.Builder()
             .baseUrl(Constants.API_URL_TARIKI)
             .client(client)
             .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
             .addConverterFactory(SimpleXmlConverterFactory.create())
             .build();
 }
 
开发者ID:BackPackerDz,项目名称:Android-Tariki.dz,代码行数:23,代码来源:ApiModuleTariki.java

示例5: initializeRetrofit

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
private void initializeRetrofit(){

        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

        retrofit = new Retrofit.Builder()
                .baseUrl(Const.BASE_API_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .client(client)
                .build();

        twohRetro = new Retrofit.Builder()
                .baseUrl(Const.BASE_URL)
                .client(client)
                .addConverterFactory(SimpleXmlConverterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
 
开发者ID:twoh,项目名称:retrofit2sample,代码行数:20,代码来源:MainActivity.java

示例6: getITHomeApi

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
public static ITHomeApi getITHomeApi() {
    if (itHomeApi == null) {
        synchronized (ITHomeApi.class) {
            if (itHomeApi == null) {
                itHomeApi = new Retrofit.Builder()
                        .baseUrl("http://api.ithome.com/")
                        .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                        .addConverterFactory(SimpleXmlConverterFactory.create())
                        .client(client)
                        .build()
                        .create(ITHomeApi.class);
            }
        }
    }
    return itHomeApi;
}
 
开发者ID:Glooory,项目名称:FlatReader,代码行数:17,代码来源:ITHomeRequest.java

示例7: main

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
public static void main(String... args) throws IOException {
  MockWebServer server = new MockWebServer();
  server.start();
  server.enqueue(new MockResponse().setBody("{\"name\": \"Moshi\"}"));
  server.enqueue(new MockResponse().setBody("{\"name\": \"Gson\"}"));
  server.enqueue(new MockResponse().setBody("<user name=\"SimpleXML\"/>"));
  server.enqueue(new MockResponse().setBody("{\"name\": \"Gson\"}"));

  com.squareup.moshi.Moshi moshi = new com.squareup.moshi.Moshi.Builder().build();
  com.google.gson.Gson gson = new GsonBuilder().create();
  MoshiConverterFactory moshiConverterFactory = MoshiConverterFactory.create(moshi);
  GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(gson);
  SimpleXmlConverterFactory simpleXmlConverterFactory = SimpleXmlConverterFactory.create();
  Retrofit retrofit = new Retrofit.Builder().baseUrl(server.url("/"))
      .addConverterFactory(
          new AnnotatedConverterFactory.Builder().add(Moshi.class, moshiConverterFactory)
              .add(Gson.class, gsonConverterFactory)
              .add(SimpleXml.class, simpleXmlConverterFactory)
              .build())
      .addConverterFactory(gsonConverterFactory)
      .build();
  Service service = retrofit.create(Service.class);

  Library library1 = service.exampleMoshi().execute().body();
  System.out.println("Library 1: " + library1.name);

  Library library2 = service.exampleGson().execute().body();
  System.out.println("Library 2: " + library2.name);

  Library library3 = service.exampleSimpleXml().execute().body();
  System.out.println("Library 3: " + library3.name);

  Library library4 = service.exampleDefault().execute().body();
  System.out.println("Library 4: " + library4.name);

  server.shutdown();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:AnnotatedConverters.java

示例8: SearchedBookLoader

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
SearchedBookLoader(Context context, String searchQuery) {
  super(context);
  this.searchQuery = searchQuery;
  requestPage = 1;
  retrofit = new Retrofit.Builder()
      .baseUrl(GoodreadsService.BASE_URL)
      .addConverterFactory(SimpleXmlConverterFactory.create())
      .build();
}
 
开发者ID:paulnunezm,项目名称:Boookito-Capstone-Project,代码行数:10,代码来源:SearchedBookLoader.java

示例9: getRetrofitClient

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
public Retrofit getRetrofitClient(String baseUrl) {
  if (retrofit == null) {
    retrofit = new Retrofit.Builder()
        .baseUrl(baseUrl)
        .addConverterFactory(SimpleXmlConverterFactory.create())
        .build();
  }
  return retrofit;
}
 
开发者ID:paulnunezm,项目名称:Boookito-Capstone-Project,代码行数:10,代码来源:BookitoApp.java

示例10: NewsDataSource

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
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);
}
 
开发者ID:hypeapps,项目名称:black-mirror,代码行数:15,代码来源:NewsDataSource.java

示例11: createService

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
static <S> S createService(Class<S> serviceClass, String apiBaseUrl, String username, String password) {
    Retrofit.Builder builder = new Retrofit.Builder()
        .baseUrl(apiBaseUrl)
        .addConverterFactory(SimpleXmlConverterFactory.createNonStrict(Factory.persister()));
    String authToken = Credentials.basic(username, password);
    builder.client(createOkHttpClient(authToken));

    return builder.build().create(serviceClass);
}
 
开发者ID:adleritech,项目名称:flexibee,代码行数:10,代码来源:RetrofitClientFactory.java

示例12: RetrofitRssFeedProvider

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
public RetrofitRssFeedProvider() {
    this.mRssFeedService = new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(SimpleXmlConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io()))
            .build()
            .create(RssFeedService.class);
}
 
开发者ID:Vovchyk,项目名称:android-rss-feed-reader,代码行数:9,代码来源:RetrofitRssFeedProvider.java

示例13: buildRetrofit

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
private static Retrofit buildRetrofit() {
    final OkHttpClient client = new OkHttpClient();
    final String endpoint = BASE_URL;

    return new Retrofit.Builder()
            .baseUrl(endpoint)
            .client(client)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(SimpleXmlConverterFactory.create())
            .build();
}
 
开发者ID:MrDyro,项目名称:KVBikeClient,代码行数:12,代码来源:ApiProvider.java

示例14: getItHomeApi

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
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;
    }
}
 
开发者ID:YiuChoi,项目名称:MicroReader,代码行数:14,代码来源:ItHomeRequest.java

示例15: getClientXml

import retrofit2.converter.simplexml.SimpleXmlConverterFactory; //导入依赖的package包/类
public static ApiEndpointInterface getClientXml() {
    if (apiInterfaceXml == null) {
        synchronized (LOCK_XML) {
            if (apiInterfaceXml == null) {
                Retrofit client = new Retrofit.Builder()
                        .baseUrl(BASE_URL)
                        .addConverterFactory(SimpleXmlConverterFactory.create())
                        .build();
                apiInterfaceXml = client.create(ApiEndpointInterface.class);
            }
        }
    }
    return apiInterfaceXml;
}
 
开发者ID:indywidualny,项目名称:Centrum.fm,代码行数:15,代码来源:RestClient.java


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