神刀安全网

Retrofit Agera Call Adapter

retrofit agera call adapter

version name: 2.0.2, version code: 1

Sample

Retrofit Agera Call Adapter

Usage

To add a dependency using Gradle:

compile 'me.drakeet.retrofit2:adapter-agera:2.0.2'  compile 'com.squareup.retrofit2:retrofit:2.0.2' compile 'com.google.android.agera:agera:1.1.0-beta1'

It supports Reservoir<T> and Reservoir<Response<T>> ,

with retrofit2, you could write your service interface like this:

interface Service {     @GET("1") Reservoir<Gank> android();     @GET("{page}") Reservoir<Response<Gank>> android(@Path("page") int page); }

And config your retrofit with agera call adapter, like this:

Retrofit retrofit = new Retrofit.Builder()     .baseUrl("http://drakeet.me/")     .client(new OkHttpClient())     .addCallAdapterFactory(AgeraCallAdapterFactory.create())     .addConverterFactory(GsonConverterFactory.create())     .build(); final Service service = retrofit.create(Service.class);

Addition

In order to avoid writing some duplicate code every time, I write a class, it is helpful:

public class Ageras {    public static <T> RepositoryCompilerStates.RFlow<T, T, ?> goToBackgroundWithInitialValue(       @NonNull final T initialValue) {     return repositoryWithInitialValue(initialValue)         .observe()         .onUpdatesPerLoop()         .goTo(Executors.newSingleThreadExecutor());   } }

Hope you will enjoy it ^ ^

License

Copyright (C) 2016 drakeet.    http://drakeet.me  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at     http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Retrofit Agera Call Adapter

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址