Note: Please read the full question and if anyone knows the answer or any suggestion feel free to tell me
I am using retrofit 2 for downloading blog data from internet in Json format and show them in a list using recycler view.I set my recyclerview adapter as a retrofit callback.
In my adapter
//..........
@Override
public void onResponse(Call<AllBlog> call, Response<AllBlog> response) {
mPosts = response.body().getPosts();
notifyDataSetChanged();
}
.....
I create a data model and make them parcelable. In MainActivity.java, I request an api call and when I get some data I saved it on onSaveInstanceState like this
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
//.....
outState.putParcelable(STATE_BLOG_LIST, value);
//.....
}
So,In onCreate when onSaveInstanceState is not null I want to pull the data from onSaveInstanceState and set the data in adapter callback in my list adapter.Something like this
if (savedInstanceState == null) {
showLoading();
Api.getBlog(mBlogListAdapter);
} else {
mBlogListAdapter.onResponse(savedInstanceState.getParcelable(STATE_BLOG_LIST), null);
}
But when I write that code this mBlogListAdapter.onResponse(savedInstanceState.getParcelable(STATE_BLOG_LIST), null);
line of code become red and says Wrong 1st argument type. Found: 'android.os.Parcelable', required: 'retrofit2.Call<io.github.niyamatalmass.treehouseblog.Model.AllBlog>
So I think:
I get a parcelable object from savedInstanceState and trying to set that in onResponse method where first paramater is Call<AllBlog> call
.
So now my question is how I convert the parcelable data to generic type(Call<AllBlog>)
.