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

[Question] Configuration #14

Open
nasibu opened this issue Nov 8, 2018 · 6 comments
Open

[Question] Configuration #14

nasibu opened this issue Nov 8, 2018 · 6 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@nasibu
Copy link

nasibu commented Nov 8, 2018

Hi Jonathan, great work! I would love to see a fully functional Glide in Xamarin. Is there a way to configure glidex from Xamarin.Android ? I saw, that you excluded the annotation package. But the official documentation says to use @GlideModule like

@GlideModule
public class YourAppGlideModule extends AppGlideModule {
  @Override
  public void applyOptions(Context context, GlideBuilder builder) {
    int diskCacheSizeBytes = 1024 * 1024 * 100; // 100 MB
    builder.setDiskCache(
        new InternalCacheDiskCacheFactory(context, "cacheFolderName", diskCacheSizeBytes));
  }
}

from Glide Documentation

@jonathanpeppers
Copy link
Owner

So I would need to look into how this actually works ^^ Hopefully it's not some gradle plugin or something that happens at build time?

Does Glide use Java reflection to find this type? It might work in Xamarin if I added the binding back for these types, and just documented how to do it.

@jonathanpeppers jonathanpeppers added enhancement New feature or request question Further information is requested labels Nov 8, 2018
@jonathanpeppers
Copy link
Owner

The way this works is via "Java Annotation Processing", which happens at build time unfortunately...

So when javac is called, you pass something like:

javac -processor com.yourpackage.GlideProcessor *.java

Then javac generates Java code that makes the plumbing behind this work. However, Xamarin.Android does not have support for augmenting it's Javac MSBuild task to supply the -processor switch...

Links on "Java Annotation Processing":

  1. https://www.baeldung.com/java-annotation-processing-builder
  2. http://hannesdorfmann.com/annotation-processing/annotationprocessing101

So what do we do?

The docs you linked to mention using the "Options" API as an alternate way to configure Glide: http://bumptech.github.io/glide/doc/options.html

Aside: They didn't have these nice docs when I wrote this thing!

The "Options" API is what I used in GlideExtensions.cs:

RequestManager request = Glide.With (imageView.Context);
RequestBuilder builder = null;

I hope this helps, is there a particular feature or toggle you need to set in your app? We may need to expose a set of options in glidex.forms so you won't have to implement your own IImageViewHandler.

@nasibu
Copy link
Author

nasibu commented Nov 12, 2018

Thank you for the quick reply. I need to configure location and size of the disk cache. In addition I have to use custom loaders. I think the only way to achieve this with Glide is to write a small Java wrapper and call this from Xamarin.Android.

@jonathanpeppers
Copy link
Owner

@nasibu post what you get working, or if you get stuck.

It might be that I can add something to make this easier to work from C#/Xamarin.

@kkarakk
Copy link

kkarakk commented Jan 3, 2019

hah i came here looking for a way to configure glide disk caching on xam.android too. guess i'm out of luck. my issue is that loading images in my recyclerview adapter with glide results in the image not loading when the activity is resumed from the call stack because of some caching error(i presume as nothing else fixed the issue).

i used requestOptions.SkipMemoryCache(true) to resolve the problem but i think this will cause issues in the future. might have to switch to FFImageLoading after all even though the performance of that is considerably slower

@jonathanpeppers
Copy link
Owner

@kkarakk can you open a new issue, maybe include a code example?

We should just fix the problem so your layout works when resuming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants