There is a problem that the image is not visible when the image is imported from the Firebase Storage and put into the ImageView.
In my opinion, the reason is that the size of the image is large.
When I import the image I am keeping, I think I need to reduce the size of the image. Is there a solution?
This is my code.
part.orderByChild("Art_ID").equalTo(art_id).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
for (DataSnapshot asnap: snapshot.getChildren()){
Log.i("ValueArtinfo", asnap.getValue().toString());
String art_filename = asnap.child("Filename").getValue(String.class);
StorageReference sart = storage.getReferenceFromUrl("gs://myaddressxxx.com/Art/" art_filename ".jpg");
// Bitmap bm = BitmapFactory.decodeFile(String.valueOf(sart));
// Bitmap bm = ShrinkBitmap(sart, 300, 300);
Glide.with(getApplicationContext() ).load(sart).into(str_art);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
throw error.toException();
}
});
And this is my firebase storage. As you can see, the file size is large and the number is about 1,000.
I tried the following solution but failed.
http://android-coding.blogspot.com/2011/06/reduce-bitmap-size-using.html
CodePudding user response:
Yes, having a 7 Mb image, can be considered a large size image. As also @GokulNathKP mentioned in his answer, you can display a thumbnail while the bigger image is loaded, but that will not solve the issue related to the size of the image.
So the best option that you have is to upload the images in smaller sizes from the beginning. You can resize them using different libraries so you can have stored in the end an image of a decent size. In that way, you can have faster downloads and lower bills to pay.
CodePudding user response:
Maybe you can just try to load the thumbnail, until the actual image is loaded in background, using Glide.
A sample code:
Glide.with(context).load("actual-url")
.placeholder(R.drawable.placeholder)
.thumbnail(0.3f) //Quality 0.1 - 1.0
.into(imageHolder);