Comments (6)
Do you have a converter for your GithubResponse
(like gson, jackson, moshi) ? You should add it after the live data response body converter.
from livedata-call-adapter.
Yes, When I add GsonConverterFactory it gives me error that require retrofit2.Converter.factory but found retrofit.Converter.factory
from livedata-call-adapter.
this is not a library problem. This is a project setup problem. If you can provide a full related files I can help you.
from livedata-call-adapter.
Also you problem is that you are using the wrong gson converter factory dependency you should use the version two (retrofit2) instead of v1.
from livedata-call-adapter.
Ok. Please have a look.
My Service Interface
public interface IRestClient {
@GET(ApiTags.GET_ORGANIZATION)
LiveData<Resource<GithubResponse>> getGithubOrganization();
}
RestClient
public static Retrofit getClient(){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(ApiTags.BASE_URL)
.addCallAdapterFactory(LiveDataCallAdapterFactory.create())
.addConverterFactory(LiveDataResponseBodyConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
return retrofit;
}
Request Handler
public void requestGithubData(LifecycleOwner context, final IResponseCallback iResponseCallback) {
this.context = context;
mRestClient = RestClient.getClient();
mRestClient.create(IRestClient.class).getGithubOrganization().observe(context,
new Observer<Resource<GithubResponse>>() {
@Override
public void onChanged(@Nullable Resource<GithubResponse> githubResponseResource) {
if (githubResponseResource.isSuccess()){
iResponseCallback.onResponse(githubResponseResource.getResource());
}else {
iResponseCallback.onError(githubResponseResource.getError().hashCode(), githubResponseResource.getError().getMessage());
}
}
});
}
from livedata-call-adapter.
You are right! I am using retrofit v1 instead of v2. Thanks
from livedata-call-adapter.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from livedata-call-adapter.