RecyclerView of Images with Problem Loading Images == null

0

Hello, everyone.

I'm doing a RecyclerView with a TextView and an ImageView that loads from the database. The problem is when this image is null. The Recycler View goes well to a certain extent and then it starts putting images that do not exist where there is == null image.

I tried Picasso and Fresco and the mistake is the same. And it is not every time that happens, only sometimes, randomly. The Views that have images are perfect.

I'm making a random so that the data is displayed randomly. Can someone help me? I'm using the following:

     Random gerador = new Random();
    position = gerador.nextInt(listadicas.size());

    final ParseObject dican = listadicas.get(position);


    holder.tituloDica.setText(dican.getString("nome"));


        if (dican.getParseFile("foto") != null) {
            holder.fotodica.setVisibility(View.VISIBLE);
            holder.fotodica.setImageURI(dican.getParseFile("foto").getUrl());

        }

Thank you

    
asked by anonymous 02.12.2016 / 05:00

2 answers

1
if (dican.getParseFile("foto") != null) {       
    holder.fotodica.setImageURI(dican.getParseFile("foto").getUrl());
}else{
    holder.fotodica.setImageURI("www.url.com/imagem.png");     
}
    
02.12.2016 / 20:47
0
if (dican.getParseFile("foto") != null) {
    holder.fotodica.setVisibility(View.VISIBLE);  
    holder.fotodica.setImageURI(dican.getParseFile("foto").getUrl());
}else{
    holder.fotodica.setVisibility(View.INVISIBLE);          
}
    
02.12.2016 / 20:43