Есть адаптер CardsAdapter:
public class CardsAdapter extends ArrayAdapter<CardView>{
private String server_ip;
public ArrayList<CardView> data;
Context mContext;
public static final int TEXT_BLOCK = 0;
public static final int TEXT_BLOCK_EXTENDED = 1;
public static final int TEXT_BLOCK_EXTENDED_URL = 2;
public static final int IMAGE_BLOCK = 3;
public static final int IMAGE_BLOCK_URL = 4;
public static final int VIDEO = 5;
public CardsAdapter(Context context, ArrayList<CardView> objects, String _server_ip) {
super(context, 0, objects);
this.server_ip = _server_ip;
this.data = objects;
mContext = context;
}
public int getItemViewType(int position) {
return getItem(position).getType();
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
int viewType = getItemViewType(position);
CardView current = getItem(position);
if( convertView == null){
switch (viewType){
case TEXT_BLOCK:
convertView = getConvertView(R.layout.card_text_block, parent);
((TextView)convertView.findViewById(R.id.card_text_block_text)).setText(current.getString("text"));
((TextView)convertView.findViewById(R.id.card_text_block_header)).setText(current.getString("header"));
break;
case TEXT_BLOCK_EXTENDED:
convertView = getConvertView(R.layout.card_text_block_extended, parent);
((TextView)convertView.findViewById(R.id.card_text_block_extended_text)).setText(current.getString("text"));
((TextView)convertView.findViewById(R.id.card_text_block_extended_header)).setText(current.getString("header"));
String thumbnail_url = String.format("http://%s:9998/%s", server_ip, current.getString("thumbnail"));
new DownloadImageTask((ImageView)convertView.findViewById(R.id.card_text_block_extended_thumbnail)).execute(thumbnail_url);
Log.d("SUPER_TAG", thumbnail_url);
break;
}
}
return convertView;
}
private View getConvertView(int layout_id, ViewGroup parent){
return LayoutInflater.from(mContext).inflate(layout_id, null);
}
}
Информация обновляется в фоне и добавляется карта с помощью .add(0, card), но почему-то всегда показывается самая первая добавленная инфа. Что не так?