Comments (15)
I don't think selector
is supported now.
from fresco.
I guess it's not, but if this library is to replace the ImageView (which i am surely want it to be), it will need to address this issue.
btw its not in the gotchas - http://frescolib.org/docs/gotchas.html#_
from fresco.
+1
It's ok not to support, especially in an initial release, but its need to be better documented. I think it's the same case xml drawables (shapes)
from fresco.
Can you give us more context on that? Since this is not an image that is being fetched from the network / file / whatever, why don't you do this instead:
mSimpleDraweeView.getHierarchy().setPlaceholderImage(resId);
mSimpleDraweeView.setUri(null);
Then if you actually need an actual image, rather than just XML drawable, switch back again:
mSimpleDraweeView.getHierarchy().setPlaceholderImage(palceholderId OR null);
mSimpleDraweeView.setUri(uri);
from fresco.
One important difference that one should be aware of is that Uri is used to specify an actual image that goes through the pipeline. That means fetching, caching, transcodng, resizing, postprocessing, etc.
Drawables are not those kind of images, don't confuse those two. Shape and similar drawables cannot go through the pipeline. What the pipeline does with images, doesn't apply to drawables.
One important consequence is the difference between the two when the resource is actually an image (e.g. PNG):
This will fetch the given PNG from the internal storage and cache it in our memory caches:
simpleDraweeView.setImageURI(Uri.parse("res://" + resPackage + resId));
This will inflate the BitmapDrawable via Resources.getDrawable(resId)
, which is subject to Android's built-in drawable cache, etc:
mSimpleDraweeView.getHierarchy().setPlaceholderImage(resId);
from fresco.
I think it's safe to close this issue.
from fresco.
@plamenko, when you are using a selector in the drawable xml, you are using actual images (im not speaking about shapes). we need to be able to set images on click/selected/unselected like the platform allows (like i wrote in the first message here), and like ImageView accepts. those images might consume a lot of memory (like in my project) and are really relevant to the issue this library tries to address.
from fresco.
The solution I provided above is as good as ImageView. In fact, it does exactly the same thing. So, you don't really lose anything by switching from ImageView.
In short, it is very unlikely that we will add a more sophisticated support for what you described.
One can specify an arbitrarily complex hierarchy of drawables in XML and parsing that XML to get to the leaf nodes that are the actual images and then rebuilding that same hierarchy, but with leaf nodes replaced with the BitmapDrawables that wrap images obtained by our pipeline seems very unfeasible. This would require us to rewrite the Android's XML inflation logic. In my opinion it's not worth the effort.
If you give us more context on what are you trying to achieve, we may be able to help you better.
from fresco.
Thank you for clearing that out. I will find a different way to handle it, this library is truely amazing and ill keep using it however i can.
from fresco.
You are welcome. But as I said, if you give us more context, we may be able to devise a better way of solving your issue.
from fresco.
I will try to clarify. I have a custom view which dynamically construct a 5 image picker, this means there are 5 images in a LinearLayout and the user needs to pick one of them according to some question. this picker is replicated a few times (could be even 10-15 times) in a ScrollView with different kind of question for each one (so this is actually a form for the user).
When the user pick one of the images, the image is changing so it would appear selected. this is why we are using selectors in drawable xml and the function image.setSelected(true), which is very comfortable.
Saving this images in the ashmem is not super important like on other parts of the app (when we are using bigger images on larger scale), but of course could be nice to have.
from fresco.
What kind of change happens when the image is selected? If it's some simple color manipulation (like making it darker), or adding some overlay, then this can be achieved easily with: overlayImage
from fresco.
It's actually a different image, and it stays that way unless the user selects a different choice in the picker. just a general question, in facebook app, do you store all images in ashmem or just the images that are consuming lots of memory?
Thanks again for all the help!
from fresco.
Fresco stores all images in ashmem on Android 4.x and lower. On Android 5.x, they are stored in the Java heap.
from fresco.
Hi, is this dead? We might need selectors for Fresco with webp images in api<18 @plamenko
If we use ImageView
it will crash because its not supported, so thats not an option.
from fresco.
Related Issues (20)
- Compiling the Fresco source code failed.
- CVE-2018-14498 from libjpeg-turbo HOT 9
- Delayed Rendering of Images with Custom Decoders HOT 4
- How to use AbstractAdaptiveCountingMemoryCache
- Compile error with new Mac Apple Chip
- OutOfMemoryError: Failed to allocate a 251648770 byte allocation [Local large images allocation issue] HOT 2
- While updating app from playstore the images not displaying properly HOT 2
- In the document, the Korean link has been cracked to some Ad link. HOT 2
- fetchWithRequest Override
- there has a memory leak, AndroidProfile tools tips me that "mCallerContext in com.facebook.imagepipeline.cache.BitmapMemoryCacheKey"。 HOT 3
- Fresco Unsatisfied Link Error
- IllegalStateException
- when update 3.1.0 Building error:Failed to transform vito-options-3.1.0.aar HOT 2
- Libwebp v1.0.0 存在CVE-2023-4863漏洞 HOT 7
- 3.1.1 Exception loading animated gif HOT 2
- GIFs do not load on v3.1.3 HOT 3
- Bug: Crash on MIUI 14.0.5 HOT 1
- React Native app crashes on startup with fresco version 3.1.3 HOT 11
- java.lang.ClassNotFoundException: Didn't find class "com.facebook.imagepipeline.nativecode.NativeJpegTranscoderFactory"
- Fresco is dying. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fresco.