Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is thumbnail(0.5f) method with glide?

Tags:

android

what is .thumbnail(0.5f) method and what is 0.5f in this method and why we need to use it in below code please explain.

Glide.with(context).load(dataList.get(position).getArtworkUrl30())
                    .thumbnail(0.5f)
                    .crossFade()

                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .into(holder.img);
like image 557
Ankesh Roy Avatar asked Nov 09 '17 13:11

Ankesh Roy


1 Answers

thumbnail(0.5f) sets the size of thumbnail relative to original size. 0.5f == 2 times smaller, or 50% of original size. Thumbnail is used to show preview (instead of placeholder or empty space) before fullsize image is loaded.

From documentation:

This method is particularly useful in combinations of ListView and detail views. If you already display the image in the ListView, let's just say, in 250x250 pixels, the image will need a much bigger resolution in the detail view. However, from the user perspective, he already saw a small version of the image, why is there a placeholder for a few seconds until the same image gets displayed again (in a higher resolution)?

In this case, it makes a lot more sense to continue to display the 250x250 pixel version in the detail view and in the background load the full resolution. Glide makes this possible with the .thumbnail() method. In this case, the parameter is a float as the size multiplier:

like image 78
JaLoveAst1k Avatar answered Oct 14 '22 10:10

JaLoveAst1k