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


Java MoshiConverterFactory类代码示例

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


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

示例1: SwapiModule

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
@Inject
public SwapiModule(OkHttpClient okHttpClient, Moshi moshi) {
    final Retrofit swapiRetrofit = new Retrofit.Builder().baseUrl(Swapi.BASE_URL)
            .client(okHttpClient)
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .build();
    bind(Swapi.class).toInstance(swapiRetrofit.create(Swapi.class));
    final Retrofit searchRetrofit = new Retrofit.Builder().baseUrl(CustomSearch.BASE_URL)
            .client(okHttpClient)
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .build();
    bind(CustomSearch.class).toInstance(searchRetrofit.create(CustomSearch.class));
    bind(SwapiListDataManager.class).singletonInScope();
}
 
开发者ID:wongcain,项目名称:okuki,代码行数:17,代码来源:SwapiModule.java

示例2: IdService

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
public IdService(HDWallet wallet, String baseUrl) {
    this.wallet = wallet;

    //final RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());
    this.client = new OkHttpClient.Builder();

    addUserAgentHeader();
    addSigningInterceptor();
    addLogging();

    final Moshi moshi = new Moshi.Builder().build();

    final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(baseUrl)
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            //.addCallAdapterFactory(rxAdapter)
            .client(client.build())
            .build();
    this.idInterface = retrofit.create(IdInterface.class);
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:21,代码来源:IdService.java

示例3: BalanceService

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
public BalanceService(HDWallet wallet, String baseUrl) {
    //final RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory
    //        .createWithScheduler(Schedulers.io());
    this.client = new OkHttpClient.Builder();
    this.client.addInterceptor(new UserAgentInterceptor());
    this.client.addInterceptor(new SigningInterceptor(wallet));

    final HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(new LoggingInterceptor());
    interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
    this.client.addInterceptor(interceptor);

    final Moshi moshi = new Moshi.Builder()
                                .add(new BigIntegerAdapter())
                                .build();

    final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(baseUrl)
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .client(client.build())
            .build();
    this.balanceInterface = retrofit.create(BalanceInterface.class);
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:23,代码来源:BalanceService.java

示例4: API

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
API(Context context, Level apiLevel) {
    this.apiLevel = apiLevel;
    final Moshi moshi = new Moshi.Builder()
            .add(Folder.class, new FolderTypeAdapter())
            .add(Feed.class, new FeedTypeAdapter())
            .add(Item.class, new ItemTypeAdapter())
            .add(User.class, new UserTypeAdapter())
            .add(Status.class, new StatusTypeAdapter())
            .build();

    converterFactory = MoshiConverterFactory.create(moshi);

    errorJsonAdapter = moshi.adapter(NewsError.class);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    String username = Preferences.USERNAME.getString(sharedPreferences);
    if (username != null) {
        String password = Preferences.PASSWORD.getString(sharedPreferences);
        String url = Preferences.URL.getString(sharedPreferences);
        setupApi(new HttpManager(username, password, HttpUrl.parse(url)));
    }
}
 
开发者ID:schaal,项目名称:ocreader,代码行数:23,代码来源:API.java

示例5: buildEthereumInterface

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
private EthereumInterface buildEthereumInterface(final String baseUrl) {
    final Moshi moshi = new Moshi.Builder()
            .add(new BigIntegerAdapter())
            .build();

    final RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory
            .createWithScheduler(Schedulers.io());

    final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(baseUrl)
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .addCallAdapterFactory(rxAdapter)
            .client(this.client.build())
            .build();
    return retrofit.create(EthereumInterface.class);
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:17,代码来源:EthereumService.java

示例6: IdService

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
private IdService() {
    final RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());
    final File cachePath = new File(BaseApplication.get().getCacheDir(), "idCache");
    this.cache = new Cache(cachePath, 1024 * 1024 * 2);
    this.client = new OkHttpClient
            .Builder()
            .cache(this.cache)
            .addNetworkInterceptor(new ReadFromCacheInterceptor())
            .addInterceptor(new OfflineCacheInterceptor());

    addUserAgentHeader();
    addSigningInterceptor();
    addLogging();

    final Moshi moshi = new Moshi.Builder()
            .add(new RealmListAdapter())
            .build();

    final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(BaseApplication.get().getResources().getString(R.string.id_url))
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .addCallAdapterFactory(rxAdapter)
            .client(client.build())
            .build();
    this.idInterface = retrofit.create(IdInterface.class);
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:27,代码来源:IdService.java

示例7: DirectoryService

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
private DirectoryService() {
    final RxJavaCallAdapterFactory rxAdapter =
            RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());
    final File cachePath = new File(BaseApplication.get().getCacheDir(), "dirCache");
    this.client = new OkHttpClient
            .Builder()
            .cache(new Cache(cachePath, 1024 * 1024 * 5))
            .addNetworkInterceptor(new ReadFromCacheInterceptor())
            .addInterceptor(new OfflineCacheInterceptor());

    addUserAgentHeader();
    addLogging();

    final Moshi moshi = new Moshi.Builder()
            .build();

    final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(BaseApplication.get().getResources().getString(R.string.directory_url))
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .addCallAdapterFactory(rxAdapter)
            .client(client.build())
            .build();
    this.directoryInterface = retrofit.create(DirectoryInterface.class);
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:25,代码来源:DirectoryService.java

示例8: ReputationService

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
private ReputationService() {
    final RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory
            .createWithScheduler(Schedulers.io());
    final File cachePath = new File(BaseApplication.get().getCacheDir(), "repCache");
    this.client = new OkHttpClient
            .Builder()
            .cache(new Cache(cachePath, 1024 * 1024))
            .addNetworkInterceptor(new ReadFromCacheInterceptor())
            .addInterceptor(new OfflineCacheInterceptor());

    addSigningInterceptor();
    addUserAgentHeader();
    addLogging();

    final Moshi moshi = new Moshi
            .Builder()
            .build();

    final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(BaseApplication.get().getResources().getString(R.string.rep_url))
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .addCallAdapterFactory(rxAdapter)
            .client(client.build())
            .build();
    this.reputationInterface = retrofit.create(ReputationInterface.class);
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:27,代码来源:ReputationService.java

示例9: CurrencyService

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
private CurrencyService() {
    final RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory
            .createWithScheduler(Schedulers.io());
    final File cachePath = new File(BaseApplication.get().getCacheDir(), "ratesCache");
    this.client = new OkHttpClient
            .Builder()
            .cache(new Cache(cachePath, 1024 * 1024))
            .addNetworkInterceptor(new ReadFromCacheInterceptor())
            .addInterceptor(new OfflineCacheInterceptor());

    addUserAgentHeader();
    addLogging();

    final Moshi moshi = new Moshi.Builder()
            .add(new BigIntegerAdapter())
            .add(new BigDecimalAdapter())
            .build();

    final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(BaseApplication.get().getResources().getString(R.string.currency_url))
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .addCallAdapterFactory(rxAdapter)
            .client(client.build())
            .build();
    this.currencyInterface = retrofit.create(CurrencyInterface.class);
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:27,代码来源:CurrencyService.java

示例10: generateSignalInterface

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
private ChatInterface generateSignalInterface() {
    final RxJavaCallAdapterFactory rxAdapter = RxJavaCallAdapterFactory.createWithScheduler(Schedulers.io());

    addUserAgentHeader();
    addSigningInterceptor();
    addLogging();

    final Moshi moshi = new Moshi.Builder()
            .build();

    final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(this.url)
            .addConverterFactory(ScalarsConverterFactory.create())
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .addCallAdapterFactory(rxAdapter)
            .client(client.build())
            .build();
    return retrofit.create(ChatInterface.class);
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:20,代码来源:ChatService.java

示例11: initRetrofit

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
private void initRetrofit() {
    final Retrofit.Builder builder;

    if (retrofit == null) {
        builder = new Retrofit.Builder();
    } else {
        builder = retrofit.newBuilder();
    }

    retrofit = builder.baseUrl(ProxerUrls.apiBase())
            .client(client)
            .addCallAdapterFactory(new ProxerResponseCallAdapterFactory())
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .addConverterFactory(new EnumRetrofitConverterFactory())
            .build();
}
 
开发者ID:proxer,项目名称:ProxerLibJava,代码行数:17,代码来源:ProxerApi.java

示例12: createRetrofit

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
private static Retrofit createRetrofit(String baseUrl, OkHttpClient okHttpClient) {
    if (okHttpClient == null) {
        okHttpClient = new OkHttpClient();
    }

    Moshi moshi = new Moshi.Builder()
            .add(new StreamTypeAdapter())
            .add(new StreamAdapter())
            .add(new VideoSizeAdapter())
            .build();

    return new Retrofit.Builder()
            .baseUrl(baseUrl)
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .client(okHttpClient)
            .build();
}
 
开发者ID:johnjohndoe,项目名称:Brockman,代码行数:18,代码来源:ApiModule.java

示例13: onOptionsItemSelected

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {
        Iron.chest().load(new Retrofit.Builder()
                .baseUrl("https://api.github.com")
                .addConverterFactory(MoshiConverterFactory.create())
                .build()
                .create(GitHubService.class)
                .listRepos("fabianterhorst"), Repo.class);
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:FabianTerhorst,项目名称:Iron,代码行数:17,代码来源:MainActivity.java

示例14: prepare

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
@Before
public void prepare() throws IOException {
    server = new MockWebServer();
    server.start();
    tokenStorage = new TestTokenStorage();
    MethodCache.DefaultMethodCache<String> methodCache = new MethodCache.DefaultMethodCache<>();
    AuthenticationHandler<String, String, String> authHandler =
            new AuthenticationHandler<>(
                    methodCache,
                    Mockito.mock(OwnerManager.class),
                    tokenStorage,
                    new TestProvider(),
                    new TestTokenTypeFactory()
            );

    Retrofit retrofit = new Retroauth.Builder<>(authHandler)
            .baseUrl(server.url("/"))
            .enableLocking(true)
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(MoshiConverterFactory.create())
            .build();

    service = retrofit.create(TestInterface.class);
}
 
开发者ID:andretietz,项目名称:retroauth,代码行数:25,代码来源:RetroauthTest.java

示例15: setUp

import retrofit2.converter.moshi.MoshiConverterFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.HEADERS);

    final OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .addInterceptor(loggingInterceptor)
            .build();

    final Moshi moshi = new Moshi.Builder().add(new OAuthScopesAdapter()).build();

    oAuth2Service = new Retrofit.Builder().baseUrl("http://localhost:" + wireMockRule.port())
            .client(okHttpClient)
            .addConverterFactory(MoshiConverterFactory.create(moshi))
            .build()
            .create(OAuth2Service.class);
}
 
开发者ID:uber,项目名称:rides-java-sdk,代码行数:18,代码来源:OAuth2ServiceTest.java


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