Help to bring ArrayList images from VC. I receive one picture, and ArrayList - I do not know how.
I get this:
public class RecyclerAdapterWall extends RecyclerView.Adapter<RecyclerAdapterWall.ViewHolder> { Context ctx; String owner_id; VKPostArray obj; Picasso picasso; private long longDate; public RecyclerAdapterWall(Context ctx, VKPostArray posts) { this.obj = posts; this.ctx = ctx; } public RecyclerAdapterWall(Context ctx, VKPostArray posts, String owner_id) { this.obj = posts; this.ctx = ctx; this.owner_id = owner_id; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_item_wall, parent, false); ViewHolder viewHolder = new ViewHolder(v); return viewHolder; } @Override public void onBindViewHolder(ViewHolder holder, final int position) { holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); VKApiPost p = obj.get(position); try { VKAttachments att = new VKAttachments(); att = p.attachments; VKApiPhoto photo = (VKApiPhoto) att.get(0); holder.imageWall.setVisibility(View.VISIBLE); holder.imageWall.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View arg0) { } }); holder.textPost.setText(p.text); holder.news_name.setText(p.post_type); holder.textlikePost.setText(" " + p.likes_count); holder.textrepostPost.setText(" " + p.reposts_count); java.util.Date time = new java.util.Date((long) p.date * 1000); holder.textDatePost.setText(String.valueOf(time)); picasso.with(ctx).load(photo.photo_604).into(holder.imageWall); //picasso.with(ctx).load().into(holder.news_ava); } catch (Exception e) { } } @Override public void onAttachedToRecyclerView(RecyclerView recyclerView) { super.onAttachedToRecyclerView(recyclerView); } @Override public int getItemCount() { return obj.size(); } public static class ViewHolder extends RecyclerView.ViewHolder{ Context ctx; CardView cv; TextView textlikePost; TextView textrepostPost; TextView textDatePost; TextView news_name; TextView textPost; ImageView imageWall, news_ava, like, repost; public ViewHolder(final View itemView) { super(itemView); cv = (CardView) itemView.findViewById(R.id.card_view_wall); news_name = (TextView) itemView.findViewById(R.id.news_name); textDatePost = (TextView) itemView.findViewById(R.id.textDatePost); textPost = (TextView) itemView.findViewById(R.id.textPost); imageWall = (ImageView) itemView.findViewById(R.id.imageWall); news_ava = (ImageView) itemView.findViewById(R.id.news_ava); textlikePost = (TextView) itemView.findViewById(R.id.tv_likes_count); textrepostPost = (TextView) itemView.findViewById(R.id.tv_reposts_count); like = (ImageView) itemView.findViewById(R.id.iv_like); repost = (ImageView) itemView.findViewById(R.id.iv_repost); }} public void clear() { obj.clear(); notifyDataSetChanged(); } }
for (VKApiPhoto photo : att) {...}- Yuriy SPb ♦