I have an custom adpter which is having public View getView(int position, View convertView, ViewGroup parent)
method.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ObjA obj = mArr.get(position);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view;
if (convertView == null) {
view = new View(mContext);
view = inflater.inflate(R.layout.grid_view, null);
} else {
view = (View) convertView;
}
// set value into bus_stop_name textView
TextView id_label = (TextView) view.findViewById(R.id.txt_ID);
TextView direction_label = (TextView) view.findViewById(R.id.txt_Direction);
id_label.setText(obj.getId()); // Setting values in view
direction_label.setText(obj.getName());
GetTiming getTiming = new GetTiming(mContext, this, obj.getId(), view);
getTiming.execute();
return view;
}
This GetTiming is AsyncTask which fetches time from Parse.com. I have interface which will call public void onGetTimings(ArrayList<Timing> timings, View view)
method.
@Override
public void onGetTimings(ArrayList<Timing> timings, View view) {
TextView time = (TextView) view.findViewById(R.id.txt_time);
busRouteTime.setText("" + timings.get(0).getTime() + "");
}
This method is getting call multiple times. Means multiple networking calls. I have other functionality which also uses Parse.com. Due to calling this method again and again, application get slow. Could anyone suggest other option to update textView in listItemView?
Can you design the app to fetch the data from parse using a single api call instead of each call for each row element? (a single api call to fetch all the data from parse OR fetch first x rows data at a time).
Then create some model to store the fetched data along with the response from parse. After this iterate through the adapter.