Frage

The library only exposed option to enable/disable caching in display options. Is there a way to avoid disc or memory cache check when loading images?

My problem is that the library always check the disc cache first. My disc cache is set with small thumbnail size. When I need to load images for screen size, I cannot skip the disc cache , it always get me the lower resolution image.

War es hilfreich?

Lösung

UIL always check caches before displaying. So there is no way to avoid without changins the sources.

But I think you can solve your problem by extending disk cache. The goal is to return non-existing file from get() method when you want to load full-sized image. So you should do as usual to load thumbnails. When you need to display full-sized image you should disable caching on disk in display options (DisplayImageOptions) and then do something like this:

((MyDiscCache) imageLoader.getDiscCache()).setIgnoreDiskCache(true);

So your cache must return any non-existing file (but not null).

When you return to display thumbnails you should "enable" (setIgnoreDiskCache(false)) disk cache back.

UPD: Create your own disk cache and set it to config.

public class MyDiscCache extends UnlimitedDiscCache {

    private boolean ignoreDiskCache;

    public MyDiscCache(File cacheDir) {
        super(cacheDir);
    }

    public MyDiscCache(File cacheDir, FileNameGenerator fileNameGenerator) {
        super(cacheDir, fileNameGenerator);
    }

    @Override
    public File get(String key) {
        if (ignoreDiskCache) {
            return new File("fakePath");
        } else {
            return super.get(key);
        }
    }

    public void setIgnoreDiskCache(boolean ignoreDiskCache) {
        this.ignoreDiskCache = ignoreDiskCache;
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top