glidex icon indicating copy to clipboard operation
glidex copied to clipboard

Use glidex only on subclass

Open Almis90 opened this issue 2 years ago • 4 comments

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?

Almis90 avatar Jun 08 '22 14:06 Almis90

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))].

jonathanpeppers avatar Jun 08 '22 14:06 jonathanpeppers

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

Almis90 avatar Jun 08 '22 15:06 Almis90

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.

jonathanpeppers avatar Jun 08 '22 16:06 jonathanpeppers

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))]

Almis90 avatar Jun 08 '22 23:06 Almis90