How I can impement two cahing strategy in one application. Eg images from one app section should be cashing in one folder and have max memory/time limit etc. And images from another section should be have another folder etc. These strategies should not depend on each other.

有帮助吗?

解决方案

ImageLoader is singleton but it provides protected constructor so you can extend ImageLoader and create the 2nd singleton:

public class ImageLoader2 extends ImageLoader {

    private volatile static ImageLoader instance;

    /** Returns singleton class instance */
    public static ImageLoader getInstance() {
        if (instance == null) {
            synchronized (ImageLoader2.class) {
                if (instance == null) {
                    instance = new ImageLoader2();
                }
            }
        }
        return instance;
    }
}

and use it with other configuration.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top