我正在尝试将json响应传递给适配器类,我从其余api获得响应,但是在改造处理程序类将json响应转换为对象数组后,json对象数组仍未传递给适配器类。我没有收到任何日志错误或警告,但是当我尝试在Android应用程序中使用此活动时,却没有任何结果。
public class Historyactivity extends AppBaseactivity {
@BindView(R.id.history_header)
RelativeLayout history_header;
@BindView(R.id.history_list)
ListView history_list;
@BindView(R.id.no_history_view)
LinearLayout no_history_view;
@BindView(R.id.hdr_back)
TextView hdr_back;
private String address;
private String category;
private String distance;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
unbinder= ButterKnife.bind(this);
backBtnSet();
updateHeader();
Intent intent=getIntent();
if(intent!=null && intent.hasExtra("mid")){
String mId=intent.getStringExtra("mid");
address=intent.getStringExtra("address");
category=intent.getStringExtra("category");
distance=intent.getStringExtra("distance");
fetchHistory(mId);
}else {
activityFinish();
}
}
private void backBtnSet() {
final int height= (int) getResources().getDimension(R.dimen.dp_24);
hdr_back.getViewTreeObserver()
.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Drawable img = getBaseContext().getResources().getDrawable(
R.drawable.ic_backarrow);
img.setbounds(0,height,height);
hdr_back.setCompoundDrawables(img,null,null);
hdr_back.getViewTreeObserver().removeonGlobalLayoutListener(this);
}
});
}
private void updateHeader() {
TextView hView= history_header.findViewById(R.id.hdr_title);
hView.setText(getString(R.string.history_small));
}
private void fetchHistory(String mId) {
JsonObject jObject=ParamConvertor.getcustomerHistory(userInfo.getId(),userInfo.getaccessKey(),mId);
Call<ArrayList<HistoryCustomer>> call=apiService.getcustomerHistory(jObject);
call.enqueue(new RetrofitHandlerFull<ArrayList<HistoryCustomer>>(this,networkHandler,1));
AppLogger.printPostBodyCall(call);
}
//Problem persists from here
private INetworkHandler<ArrayList<HistoryCustomer>> networkHandler
= new INetworkHandler<ArrayList<HistoryCustomer>>() {
@Override
public void onResponse(ArrayList<HistoryCustomer> data,String msg,int num) {
if(data!=null && !data.isEmpty()){
updateList(data);
dataPresent(true);
}else{
dataPresent(false);
}
}
@Override
public void onFailure(String msg,int error) {
dataPresent(false);
}
};
private void updateList(ArrayList<HistoryCustomer> data){
HistoryAdapter adapter=new HistoryAdapter(this,data,address,category);
history_list.setadapter(adapter);
}
private void dataPresent(boolean isPresent){
if(isPresent){
no_history_view.setVisibility(View.GONE);
history_list.setVisibility(View.VISIBLE);
}else{
no_history_view.setVisibility(View.VISIBLE);
history_list.setVisibility(View.GONE);
}
}
@OnClick(R.id.hdr_back)
void onCLicks(View view){
switch (view.getId()){
case R.id.hdr_back:
activityFinish();
break;
}
}
}