Reputation: 21
I am developing an app, using firebase, which reads images from firebase storage into listview using glide. Do you know what's the best way to download images into listview items?
Upvotes: 0
Views: 5613
Reputation: 321
• Try to add app-level Dependency
dependencies {
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:0.6.0'
}
• Use the next code to get the image from firebase storage
ImageView imageView = findViewById(R.id.image_view);
Glide.with(context)
.using(new FirebaseImageLoader())
.load(pathReference )
.into(imageView);
Upvotes: 0
Reputation: 25134
Version 0.6.0
of the FirebaseUI-Android library includes the ability to take a Firebase StorageReference
and load an image using Glide:
// Reference to an image file in Firebase Storage
StorageReference storageReference = ...;
// ImageView in your Activity
ImageView imageView = ...;
// Load the image using Glide
Glide.with(this /* context */)
.using(new FirebaseImageLoader())
.load(storageReference)
.into(imageView);
To include it, just add compile 'com.firebaseui:firebase-ui-storage:0.6.0'
to your build.gradle
.
Upvotes: 1
Reputation: 4155
I'm not acquainted with Firebase Storage, but I suppose that when you upload a image into this platform, they give you an URL in order to access to this resource. Well, if this is correct, try this code in your adapter class for the ListView:
ImageView img = (ImagenView)findViewbyid(R.id.myimageview);
String url = "http://..."; //Firebase URL to the picture
Glide.with(yourActivity).load(url).into(img);
Do not forget to modify your gradle file with Glide path.
repositories {
mavenCentral()
}
dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:19.1.0'
}
Hope it helps!
Upvotes: 1
Reputation: 759
If you are using glide you can use it to fill ImageView in ListView. Glide has method into
e.g.
final ImageView myImageView;
Glide
.with(myFragment)
.load(url)
.centerCrop()
.placeholder(R.drawable.loading_spinner)
.crossFade()
.into(myImageView);
Upvotes: 4