2014-04-02 35 views
0

如何在一個應用程序中阻止兩種緩存策略。例如,來自一個應用程序部分的圖像應該在一個文件夾中兌現,並且具有最大內存/時間限制等。而來自另一部分的圖像應該具有另一個文件夾等。這些策略不應該相互依賴。如何在UIL中實現兩種緩存策略

回答

0

ImageLoader的是單身,但它提供了受保護的構造這樣可以延長ImageLoader並創建第二單:

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; 
    } 
} 

,並與其他配置中使用它。