I am trying to retrieve data from the database to a recyclerview but the only name of an image is showing in the recyclerview. The image is not getting load in image . Here
I will Assume that this is the database:
Uploads
|
|---------someID
|
|----name:"...."
image:"..........."
---------someID
|
|----name:"...."
image:"..........."
If your database is some thing like this in onBindViewHolder
:
FirebaseRecyclerAdapter<HealthTips, hViewHolder> adapter= new FirebaseRecyclerAdapter<HealthTips, hViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull final hViewHolder holder, int i, @NonNull final HealthTips healthTips) {
//directly get the values like this
String Iname = healthTips.getName();
String Uimage = healthTips.getImage();
holder.hName.setText(Iname);
Picasso.get().load(Uimage).into(holder.hImageview);
}
...............
..............
According to your database your HealthTips
must be like this:
public class HealthTips {
private String name, imageUrl;
public HealthTips(){
}
public HealthTips(String name, String imageUrl){
this.name = name;
this.imageUrl = imageUrl;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getImageUrl(){
return imageUrl;
}
public void setImageUrl(String imageUrl){
this.imageUrl= imageUrl;
}
}
UPDATE----------
I think you are uploading the url wrong to database, maybe try this in onSuccess()
of the uploadFile()
:
........
........
Toast.makeText(Admin.this, "Upload Successful",Toast.LENGTH_SHORT).show();
//get download url
fileReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
//this is the url to post to database
Upload upload = new Upload(mEditTextFileName.getText().toString().trim(),uri.toString());
//upload
String uploadId = mDatabaseRef.push().getKey();
mDatabaseRef.child(uploadId).setValue(upload);
}
............
............