我的回复电话:
public void getFeed() {
if (ApiClient.isNetworkAvailable(getActivity()))
{
final ProgressDialog progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage(getActivity().getString(R.string.txt_please_wait));
progressDialog.show();
Call<List<ApiOrderListBean.DataBean.OrdersBean.AssignToBean>> call = ApiClient.getAPIService().getAllData();
call.enqueue(new Callback<List<ApiOrderListBean.DataBean.OrdersBean.AssignToBean>>() {
@Override
public void onResponse(Call<List<ApiOrderListBean.DataBean.OrdersBean.AssignToBean>> call, Response<List<ApiOrderListBean.DataBean.OrdersBean.AssignToBean>> response)
{
if (mDialog.isShowing()) {
mDialog.dismiss();
}
List<ApiOrderListBean.DataBean.OrdersBean.AssignToBean > list = response.body();
for(int i=0; i < list.size(); i++)
{
ApiOrderListBean.DataBean.OrdersBean.AssignToBean toBean= list.get(i);
SaveIntoDatabase task = new SaveIntoDatabase();
task.execute(toBean);
LinearLayoutManager layoutmanager = new LinearLayoutManager(getActivity());
mOrderAdapter = new RecyclerViewAdapterOrder(list);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(layoutmanager);
recyclerView.setAdapter(mOrderAdapter);
}
Log.d(TAG, "layout skkiped" + response.message());
}
@Override
public void onFailure(Call<List<ApiOrderListBean.DataBean.OrdersBean.AssignToBean >> call, Throwable t) {
}
});
}
}
POJO是差异,但如果我想要ContactDetailBean,它将与AssignToBean相同:
public class ManufacturerList extends BaseResponse
{
private String message;
private boolean status;
private DataBean data;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public DataBean getData() {
return data;
}
public void setData(DataBean data) {
this.data = data;
}
public static class DataBean {
private Object deletedManufacturers;
private List<ManufacturersBean> manufacturers;
public Object getDeletedManufacturers() {
return deletedManufacturers;
}
public void setDeletedManufacturers(Object deletedManufacturers) {
this.deletedManufacturers = deletedManufacturers;
}
public List<ManufacturersBean> getManufacturers() {
return manufacturers;
}
public void setManufacturers(List<ManufacturersBean> manufacturers) {
this.manufacturers = manufacturers;
}
public static class ManufacturersBean {
private int id;
private ContactDetailBean contactDetail;
private int createdBy;
private String name;
private String lastUpdated;
private String dateCreated;
private String code;
private boolean deleted;
private int updatedBy;
private List<Integer> categories;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public ContactDetailBean getContactDetail() {
return contactDetail;
}
public void setContactDetail(ContactDetailBean contactDetail) {
this.contactDetail = contactDetail;
}
public int getCreatedBy() {
return createdBy;
}
public void setCreatedBy(int createdBy) {
this.createdBy = createdBy;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLastUpdated() {
return lastUpdated;
}
public void setLastUpdated(String lastUpdated) {
this.lastUpdated = lastUpdated;
}
public String getDateCreated() {
return dateCreated;
}
public void setDateCreated(String dateCreated) {
this.dateCreated = dateCreated;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public boolean isDeleted() {
return deleted;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
public int getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(int updatedBy) {
this.updatedBy = updatedBy;
}
public List<Integer> getCategories() {
return categories;
}
public void setCategories(List<Integer> categories) {
this.categories = categories;
}
public static class ContactDetailBean {
private Object id;
private Object emailId;
private Object phone;
private Object fax;
private Object postalCode;
private Object state;
private Object longitude;
private Object latitude;
private Object addressLine2;
private Object addressLine1;
private Object mobile;
private Object country;
private Object city;
public Object getId() {
return id;
}
public void setId(Object id) {
this.id = id;
}
public Object getEmailId() {
return emailId;
}
public void setEmailId(Object emailId) {
this.emailId = emailId;
}
public Object getPhone() {
return phone;
}
public void setPhone(Object phone) {
this.phone = phone;
}
public Object getFax() {
return fax;
}
public void setFax(Object fax) {
this.fax = fax;
}
public Object getPostalCode() {
return postalCode;
}
public void setPostalCode(Object postalCode) {
this.postalCode = postalCode;
}
public Object getState() {
return state;
}
public void setState(Object state) {
this.state = state;
}
public Object getLongitude() {
return longitude;
}
public void setLongitude(Object longitude) {
this.longitude = longitude;
}
public Object getLatitude() {
return latitude;
}
public void setLatitude(Object latitude) {
this.latitude = latitude;
}
public Object getAddressLine2() {
return addressLine2;
}
public void setAddressLine2(Object addressLine2) {
this.addressLine2 = addressLine2;
}
public Object getAddressLine1() {
return addressLine1;
}
public void setAddressLine1(Object addressLine1) {
this.addressLine1 = addressLine1;
}
public Object getMobile() {
return mobile;
}
public void setMobile(Object mobile) {
this.mobile = mobile;
}
public Object getCountry() {
return country;
}
public void setCountry(Object country) {
this.country = country;
}
public Object getCity() {
return city;
}
public void setCity(Object city) {
this.city = city;
}
}
}
}
}
我打电话给片段
private void loadOrderFeed() {
mDialog = new ProgressDialog(getActivity());
if (getNetworkAvailability()) {
getFeed();
} else {
getFeedFromDatabase();
}
}
onCreateView 中的
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//Returning the layout file after inflating
view = inflater.inflate(R.layout.recent_order_list, container, false);
dBhelper = new DBhelper(getActivity(), getContext().getFilesDir().getAbsolutePath());
try
{
dBhelper.prepareDatabase();
}
catch (IOException e)
{
e.printStackTrace();
}
loadOrderFeed();
return view;
}
我没有在response.body()中得到响应,而调试是在POJO中有任何问题,或者这些类是在另一个中创建的,是不是? 我是android的新手。 任何人都可以建议在这种情况下做什么?
答案 0 :(得分:0)
通过在retrofitinterface中添加标题来解决问题。