@molinch Can you tell me more about FFImageLoading.Work.ImageSource.ApplicationBundle ImageSource type? I wanted to implement placeholders (Loading and Error) for Xamarin.Forms renderer and I can't get it working. How should I use it to get images from iOS / Android resources described here:
For iOS it's easy, it's just like you said even though only the exact same filename will be used, there is no special loading for double/triple retina images.
For Android you will need to add images as Assets instead of Resources.
Ok, thanks for the info. But can you tell me why do you use Assets instead of Resources on Android? I wanted to unify this on both iOS and Android. Second questions do Placeholders work with http image sources? Or should I only use local images? How does it work? Does it download placeholder first?
@daniel-luberda, @molinch I've faced similar issue and changed the behavior for getting image from ApplicationBundle source type in my fork - see if that works for you (refer to resources by their string name in drawable-** folder)
I've also created a pull request for that - https://github.com/molinch/FFImageLoading/pull/38
Cheers
@daniel-luberda Basically Resources on Android != BundleResource on iOS.
A BundleResource on iOS is much more like an Asset on Android.
Android resources are accessed by int value rather than by their filename. Please note that loading them by name is still possible but discouraged and slower: http://developer.android.com/reference/android/content/res/Resources.html#getIdentifier%28java.lang.String,%20java.lang.String,%20java.lang.String%29
Placeholders can come from Disk, ApplicationBundle or Url. Example:
C#
ErrorPlaceholder(IMAGE_PLACEHOLDER, FFImageLoading.Work.ImageSource.ApplicationBundle)
Here we load from the bundle but can specify another ImageSource.
@petlack Thanks for your PR! :+1:
I will reply directly in the PR message then
@petlack Cool! It's just what i needed to add Placeholders for Xamarin.Forms. Can we change FFImageLoading.Work.ImageSource.ApplicationBundle for eg. ApplicationResource or similar for compatibility?
Note: use of this function is discouraged. It is much more efficient to retrieve resources by identifier than by name.
@molinch Thanks for the information! Yes, there's a performance hit when loading resources by name but Xamarin.Forms preferred way is to use Resources. It should work the same on iOS and Android. It would be really cool to merge this PR (as another ImageSource type).
If you want to test it you can play with this Alpha Nuget
https://www.nuget.org/packages/Xamarin.FFImageLoading/1.1.6-alpha1
Thanks! I'm sending the PR request for a few minutes
Maybe I don't understand the answers but I need to know.
On IOS, I have an image asset with image.png, [email protected] and [email protected] in it.
So when I want that the place holder display this asset I just need to call LoadingPlaceholder("image.png", ImageSource.ApplicationBundle) and the service will load image.png or the other two depending the needs on display (retina or not) ?
Or I need to write LoadingPlaceholder("[email protected]", ImageSource.ApplicationBundle) to have [email protected] if it needed ?
I read another issue (#94) and a comment say
: On iOS assets are compiled so I will go for ImageSource.CompiledResource
So I need to use ImageSource.ApplicationBundle or ImageSource.CompiledResource to access to an IOS image asset ?
Sorry to ask this type of question again, but dispite of reading all issue on bundles I do not find an answer as clear as I need to :)
Thank you.
@MrGrabazu For images in xcassets use LoadingPlaceholder("image", ImageSource.CompiledResource)
Thanks ! :)
Most helpful comment
@MrGrabazu For images in xcassets use LoadingPlaceholder("image", ImageSource.CompiledResource)