Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use glidex only on subclass #107

Open
Almis90 opened this issue Jun 8, 2022 · 4 comments
Open

Use glidex only on subclass #107

Almis90 opened this issue Jun 8, 2022 · 4 comments

Comments

@Almis90
Copy link

Almis90 commented Jun 8, 2022

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?

@jonathanpeppers
Copy link
Owner

You'd probably need to include glidex.forms source code in your project, and change this custom renderer:

[assembly: ExportRenderer (typeof (Image), typeof (Android.Glide.ImageRenderer))]
namespace Android.Glide
{
public class ImageRenderer : Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer

To something like [assembly: ExportRenderer (typeof (GlideImage), typeof (Android.Glide.ImageRenderer))].

@Almis90
Copy link
Author

Almis90 commented Jun 8, 2022

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

@jonathanpeppers
Copy link
Owner

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.

@Almis90
Copy link
Author

Almis90 commented Jun 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants