我在应用程序中使用Retrofit
。我需要调用两个Web服务来将数据设置为RecyclerView
。从第一次JSONArray
调用中得到GET
。格式为
[
{
"id": 2,
"status": "W",
"myId": 2
},
{
"id": 1,
"status": "W",
"myId": 1
}
]
我需要从此myId
获取JSONObject
,并且需要以http://www.example.com/api/myInfo/myId
的身份调用另一个Web服务来获取另一个响应。由于第二个Web服务调用依赖于1,因此我想同时获取数据并将其设置为RecyclerView
适配器。目前,我将该服务称为
getCalls.getInfo().enqueue(new Callback<ArrayList<QueuePojo>>() {
@Override
public void onResponse(Call<ArrayList<QueuePojo>> call, Response<ArrayList<QueuePojo>> response)
{
entry=response.body();
adapter=new QueueAdapter(entry,MainActivity.this);
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
}
@Override
public void onFailure(Call<ArrayList<QueuePojo>> call, Throwable t) {
}
});
如何在翻新中进行这样的依赖调用,最后将数据设置到RecyclerView Adapter?