I keep having this issue in my code. From the code below, I think I already checked if the load() value is null. If it's null, the code should never reach Picasso.
My app allows users to give comments or upload photos to a dish (like yelp). However, they're not required to post both. So there could be data have only comment or photo. So, I'm not sure if that's something that causes the problem.
This is the database where I wanna retrieve from:
To explain my code a little:
- Check if the dataSnapshot1 has image value;
- if yes, then check if the dishName matches this dish;
- if yes, then put the photo on the imageView.
Code:
mdatabaseReferece1 = FirebaseDatabase.getInstance().getReference("Post");
mdatabaseReferece1.addValueEventListener(new ValueEventListener() {
@Override
for (DataSnapshot dataSnapshot1 : dataSnapshot.getChildren()){
if (dataSnapshot1.child("image").getValue()!=null){
if (dataSnapshot1.child("dishName").getValue().toString().equals(newDish)) {
ImageView imageView = findViewById(R.id.gallery_photo);
Picasso.get().load(dataSnapshot1.child("image").getValue().toString()).into(imageView);
gallery.addView(view);}
}
}
}
I don't have to use Picasso if there's any other easier way. All I want to have on my app is a list of matched photos retrieved from the firebase.