glidex
glidex copied to clipboard
Use glidex only on subclass
Is there any way to make glidex work only on my own custom subclass? e.g.
public class GlideImage : Image
{
}
and leave all my Image as they are?
You'd probably need to include glidex.forms source code in your project, and change this custom renderer:
https://github.com/jonathanpeppers/glidex/blob/e9158efd13e56c3750bb150c3056cce946c9dfa0/glidex.forms/ImageRenderer.cs#L4-L8
To something like [assembly: ExportRenderer (typeof (GlideImage), typeof (Android.Glide.ImageRenderer))]
.
That gave me an idea to make my own custom renderer and use the extensions for glide only where I need it. I didn't call Android.Glide.Forms.Init(this);
in my MainActivity but I still had the issue where it doesn't show images from embedded resources. Does it still override something even if you don't call Init?
Edit: Nevermind found the code that causing it
I think if you add glidex.forms to your project at all, it's going to use the above ImageRenderer
. The Init()
method is mainly there to ensure the linker doesn't remove it -- if you use it other places, same thing.
For my case commenting out stream image source worked, now my embedded resources are not handled by ImageViewHandler. It's a temporary solution until I find more time to for a better solution.
//[assembly: ExportImageSourceHandler (typeof (StreamImageSource), typeof (Android.Glide.ImageViewHandler))]