http://www.jianshu.com/p/5364957dcf49
Before you begin
If you have the experience of using, skill, stepping on the pit, hoping to contribute, I will slowly add in Todo (^^)
About Fresco
Fresco 是一个强大的图片加载组件。 Fresco 中设计有一个叫做*image pipeline*的模块。它负责从网络,从本地文件系统,本地资源加载图片。为了最大限度节省空间和CPU时间,它含有3级缓存设计(2级内存,1级文件)。 Fresco 中设计有一个叫做*Drawees*模块,方便地显示loading图,当图片不再显示在屏幕上时,及时地释放内存和空间占用。 Fresco 支持 Android2.3(API level 9) 及其以上系统。
And if you don't know what fresco is? Then the proposal must be understood: Fresco official documents; At the same time, it is recommended to read the document in preference for reading English documents, because the Chinese version of the document may have a lag situation, which will avoid a lot of unnecessary trouble. In addition, when a problem arises, it is recommended to go to its fresco Github issues to do a search, here is a lot of fresco use and problems of feedback and answers, often may solve some of your basic doubts, even your own open New issue is also not.
Using fresco
This is not actually the purpose of my writing this article, because the official document is sufficiently detailed for use, and many blogs have been interpreted and used to guide, even to run reading and demo.
What the? Want to study here also study, OK, people are lazy, besides our programmer ~~!
So, I'll simply do a collection (also not Google or Baidu or ...) Other search engines):
If you think you have a better link, please recommend it!
Chinese documents
http://www.fresco-cn.org/ ; 如果真心读不懂英文或者不想读, 那么这里,你可以去看看。
Import Official sample
http://www.cnblogs.com/stay/p/4398432.html; 简单看了下,还不错, 讲的相对详细,我并未细看。因为其实导入和编译项目该是开发的基本功吧,(*^__^*) 嘻嘻……
Simple to use
http://blog.csdn.net/y1scp/article/details/49245535; 非常详细的使用教程了吧,作者还是比较有心的,点个赞。
Advanced Research
1.Fresco Source parsing-local compilation
2.Fresco Source code Parsing-Hierarachy-view-controller
3.Fresco Source code Parsing-Draweeview
4.Fresco source code Parsing-initialization process analysis
5.Fresco source code parsing-DataSource How to store data
This is the author of a series of blog bar, the specific content has not time to peruse, but can persist in writing, visible very patient.
Update Advanced 1:2015/12/22
Busy last night to visit Weibo, found a 0.7.0 version of Fresco source parsing, looked at, is very good, this update is recommended to you:
Fresco-source-analysis
Now see the best fresco the source of the interpretation of it
Demo
Kaede
Fresco-sample-usage
This is a good example of the project, you can refer to a lot of things, specific introduction to the project, to see Doc, or Jane's open-source Android image loading library Fresco Demo project is also introduced;
Huqiu Liao
Fresco-demo-for-gradle
Autumn million works, Absolute boutique. There is a simple contrast of a picture loading open source, the usage is also many, very has the reference value. It is worth mentioning that seemingly Chinese documents are also autumn million works FRESCO-DOCS-CN, you can go to observe, I am not sure, but the feeling is.
The pain of using the Open Source Library
Fresco powerful, but not perfect, but has been updated, so, regardless of your use, are recommended to continue to pay attention to the development of Open Source Library and update, because perhaps, there will be good news, let you learn, make you relaxed.
I am very appreciative of open source author's various open source works, but also happy to use, but the open source Library, there are always a lot of unsatisfactory place, which is often said, pit ~
Yes, that's the point of this article.
I use the fresco library in my new project, thank you very much facebook~
Actual use, will encounter a variety of problems, and I write, but only because some problems, it is worth our attention, write down, to prevent their next time, at the same time, also to encounter similar problems of some reference it:
In general, after the direct fresco.initialized (context) is initialized, the following references are made in the layout
<com.facebook.drawee.view.SimpleDraweeView android:id="@+id/my_image_view" android:layout_width="130dp" android:layout_height="130dp" fresco:placeholderImage="@drawable/ic_launcher" />
Can already handle most of the situation, and do not have to worry about other problems;
Wait : Spit trough, incredibly wide-high base use is required to set the specific DP value
However, I am in use, it is used to do the album Multi-choice (since the sin, (⊙﹏⊙) b):
So here's the question,
The first problem is oom ...
Well, can this powerful library also be oom?
All know, multi-image loading is really good memory, but the other three-party library is OK wow, what situation?
Of course, the use of posture is not quite right, yes, Gongge display is a large map display, resulting in drag, so, did the optimization:
public static void showThumb(Uri uri, SimpleDraweeView draweeView){ ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri) .setResizeOptions(new ResizeOptions(DensityUtil.dip2px(144), DensityUtil.dip2px(144))) .build(); DraweeController controller = Fresco.newDraweeControllerBuilder() .setImageRequest(request) .setOldController(draweeView.getController()) .setControllerListener(new BaseControllerListener<ImageInfo>()) .build(); draweeView.setController(controller); }
At first glance, good cool, automatically for me resize the picture, also take a method, good reuse, good cool, O (∩_∩) o~;
Tip: If there is a problem after resize, then maybe the problem of parameter setting, look at the size of the wide and high
Run a test, ah ~ sliding smoothly ... Is that good? Oh~no, new problems have arisen,
The picture is incomplete (shown as pure white, or pure black)
What the heck?
is also doubts abnormal, before resize can show before, how now instead of some show? Is there something wrong with this method?
Then view the official document resizing, read the hearts of the big call: French ~ details, details, details
[Email protected] ' Evu%3.png
The document is very clear, this method only supports JPG, only jpg, support jpg, inner
At this time is a crash, mind, only support jpg how enough, now PNG, WEBP of various formats how to do ...
Look down, okay, haha, please allow me to be happy, yes, the official provides a way to support more formats:
(5lx_1o0v997km$jl5r_ulr.png
Tip: Remember here, not setdownsampleenabled (true), but also to call the previous resize method, the document also said very clearly
Well, maybe even so, some people still do not know how to set this property, in fact, it is very simple wow, they can be defined by the configuration of Wow, the initialization of the time to define :
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this) .setDownsampleEnabled(true) .build();Fresco.initialize(this, config);
Well, yes, fresco and other picture loading frameworks, as well as support for customizing some Config properties, support a lot, what Diskcacheconfig, Imagepipelineconfig, memorycacheparams, etc. See the official documentation for brain repair.
Well, whether the problem is solved, I run to see, OK, before the white screen place, the picture came out, sliding to see it, also good oh.
More
Of course, there are still a lot of problems to use, I will use the same time continue to update some, so that I can know the new.
In addition, I like to be good people, if you lazy, then, when you have problems, there are a few places you have to look at:
Fresco Issue 567 Here are some PNG images showing the toomanybitmapsexception
Fresco Issue 84 can refer to a review of the process of solving the problem
Fresco Issue 738 do not know how to set the cache? Can be used as a reference
I also individually configured a very detailed config, you can also be personalized according to their own needs to configure.
Todo 2015/12/18
此处占坑, 用来总结更多~~
End
Many times, know that strong things are not enough, we will use, will not be enough, even have to study how to use more refined, with fine for a lot of people still not enough, because also know its principle, even learn and build themselves;
Finally, I am on the road of technical exploration, suffering from the usual work pressure, time is relatively small, inevitably write the process of omission, or even more, if it happens, you see there is a problem, or there are suggestions to modify, then, please put forward, help me progress, thank you ~
Wen/aegis (author of Jane's book)
Original link: http://www.jianshu.com/p/5364957dcf49
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".
"Turn" fresco the pain of the strong