Image cache configuration guide for glide loading Library in Android

Zero. Choose glide. Why do I recommend glide first?

Many image loading frameworks are used, including afinal bitmap of afinal framework, bitmaputils of xutils, universal imageloader, Picasso of square, a famous open source organization, glide recommended by Google, and fresco launched by Facebook. I have experienced all these before and after, so how to choose in the face of so many frameworks? Here is a brief analysis of my views.

Afinal and xuils have stopped maintenance on GitHub. The latest framework of the open source community belongs to kjframework. However, this rapid development framework seems to be very easy to use and has all kinds of functions. I don't recommend small projects or large projects. In this way, the coupling degree of the project is too high. Once the maintenance is stopped and new problems are increasing, it will be troublesome for no one to deal with them.

Before glass and fresco came out, the most popular ones at that time were universal imageloader and Picasso. At that time, I felt that the configuration of universal imageloader was more troublesome than Picasso. Although various configurations were provided, I didn't practice them. I didn't know how to configure them at all. It was better to adopt the default configuration. I chose Picasso as the image loading framework for nearly a year, There are not too many problems, and the use is simple, perhaps because the previous project is too simple and the cycle is not very long. In addition, a big problem has not been exposed when using eclipse development. With the latest Android studio, you can clearly see various performance related monitoring, such as CPU and memory monitoring, Finally, I know that the previous projects are so jammed. Picasso loads slightly larger pictures, which is particularly memory consuming. Usually, a listview or top sliding advertising bar contains multiple pictures, which makes the pages that contain more pictures abnormally jammed (previously, it was attributed to the bad tester), Knowing this, I kind of want to replace Picasso, but this time I can't be so careless.

Picasso, glass, universal imageloader and fresco have been tested. The test contents are as follows: memory test, large picture test, small picture test, local picture and network picture. Of course, their characteristic functions are experienced in combination with official documents. In memory test, glass, universal imageloader and fresco perform very well, Picasso is really terrible. The difference between small pictures is not very big. The memory consumption of slightly larger pictures is several times higher than that of others. This proves my guess. Picasso can no longer be used. The following analysis of other frameworks shows that fresco's performance in large picture tests higher than 2m is as direct as Picasso, In the project, it is impossible to realize the large picture preview function. Then, look at the results of universal imageloader and glide in these tests. How to choose?

Because I used Picasso before the project, the usage of glass is almost another Picasso. There are relatively few changes from Picasso to glass. Another point is that this project is maintained by Google, and I can give it more trust. Compared with universal imageloader, glass can support GIF and short video, and needs to be used later, Here I have to talk about the excellent caching mechanism of glide. By default, rgb565 is used for glide picture caching, which is equivalent to argb8888. It can save a lot of space, support the linkage with the life cycle of activity, fragment and application, and manage picture requests more intelligently. Of course, there are other extensions to see more? Glide introduction? Of course, the number of glide methods is more than 1000 than that of universal imageloader. Those who encounter 64K problems will pay more attention to this.

Just now I just skimmed over fresco. In fact, I have great expectations for him, because there are many unstable places just coming out. There are a large number of functions that attract me. It supports webps format (like JPG, it is lossy compression format, and images of the same quality in webps save more space), supports progressive JPEG, and can easily customize various image attributes, Support multi graph request and picture reuse, and support gesture scaling and rotation, etc. more introduction? Fresco, of course, is not so good in actual use, and many functions need to be improved.

There is also a little detail to note. It's best not to use it directly. At least it is simply encapsulated by itself, rather than directly used in the project. For a simple example, there are too many pictures in the later stage. It may be necessary to configure another machine to store pictures separately. The host address is configurable, but don't work overtime for a simple demand.

1、 New features since glide 3.0

1. Dynamic GIF image loading:

Glide.with(context).load(...).asBitmap() //显示gif静态图片
Glide.with(context).load(...).asGif() //显示gif动态图片

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>