I can not start downloading pictures from VC via json ... Everything is displayed, except for the picture ... My Picasso seems to work, but the pictures do not display ((((Tell me what is nitak ??

I do this:

VKRequest reqWall=VKApi.wall().get(VKParameters.from(VKApiConst.OWNER_ID, -1, VKApiConst.EXTENDED, 1, VKApiConst.COUNT, 100 , "text")); reqWall.setPreferredLang("ru"); reqWall.executeWithListener(new VKRequest.VKRequestListener() { @Override public void onComplete(VKResponse response) { super.onComplete(response); JSONObject jsonObject = response.json; String owner = null; try { owner = (((JSONObject) ((JSONArray) ((JSONObject) jsonObject.get("response")).get("items")).get(0)).getString("owner_id")); } catch (JSONException e) { e.printStackTrace(); } VKPostArray posts = new VKPostArray(); try { posts.parse(response.json); } catch (JSONException e) { e.printStackTrace(); } try { JSONArray array = ((JSONArray) ((JSONObject) jsonObject.get("response")).get("groups")); } catch (JSONException e) { e.printStackTrace(); } VKApiPost p = posts.get(0); VKAttachments at = p.attachments; VKAttachments.VKApiAttachment test = at.get(0); try { Log.v("test", (((JSONObject) ((JSONArray) ((JSONObject) jsonObject.get("response")).get("profiles")).get(0)).getString("id"))); } catch (JSONException e) { e.printStackTrace(); } RecyclerView rv = (RecyclerView) findViewById(R.id.userWall); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext()); rv.setLayoutManager(linearLayoutManager); RecyclerAdapterWall adapterWall = new RecyclerAdapterWall(getApplicationContext(), posts); rv.setAdapter(adapterWall); 

==============

 public class RecyclerAdapterWall extends RecyclerView.Adapter<RecyclerAdapterWall.ViewHolder>{ Context ctx; String owner_id; VKPostArray obj; public RecyclerAdapterWall(Context ctx, VKPostArray posts){ //super(ctx,R.layout.recycler_item_wall); this.obj= posts; this.ctx= ctx; } public RecyclerAdapterWall(Context ctx, VKPostArray posts, String owner_id){ //super(ctx,R.layout.recycler_item_wall); 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, int position) { final VKApiPost p= obj.get(position); holder.imageWall.setVisibility(View.VISIBLE); holder.textPost.setText(p.text); java.util.Date time= new java.util.Date((long)p.date*1000); holder.textDatePost.setText(String.valueOf(time)); try{ Picasso.with(ctx).load(String.valueOf(p.attachments.get(position))).into(holder.imageWall); }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{ CardView cv; TextView textNamePost; TextView textDatePost; TextView textPost; ImageView imageWall; public ViewHolder(View itemView) { super(itemView); cv=(CardView) itemView.findViewById(R.id.card_view_wall); textDatePost=(TextView)itemView.findViewById(R.id.textDatePost); //textNamePost=(TextView)itemView.findViewById(R.id.textNamePost); textPost=(TextView)itemView.findViewById(R.id.textPost); imageWall=(ImageView)itemView.findViewById(R.id.imageWall); } } } 

    1 answer 1

    I spent so much time waiting for an answer and did not wait for such a simple answer .....

    While waiting, I did everything myself .....

     public class RecyclerAdapterWall extends RecyclerView.Adapter<RecyclerAdapterWall.ViewHolder>{ Context ctx; String owner_id; VKPostArray obj; Picasso picasso; 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, int position) { 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.textPost.setText(p.text); holder.textlikePost.setText("Лайкнули: " + p.likes_count+ " " + "Поделились: " + 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); }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{ CardView cv; TextView textlikePost; TextView textDatePost; TextView textPost; ImageView imageWall; public ViewHolder(View itemView) { super(itemView); cv=(CardView) itemView.findViewById(R.id.card_view_wall); textDatePost=(TextView)itemView.findViewById(R.id.textDatePost); textlikePost=(TextView)itemView.findViewById(R.id.textLikePost); textPost=(TextView)itemView.findViewById(R.id.textPost); imageWall=(ImageView)itemView.findViewById(R.id.imageWall); }}}