Class LruResourceCache

    • Constructor Detail

      • LruResourceCache

        public LruResourceCache​(long size)
        Constructor for LruResourceCache.
        Parameters:
        size - The maximum size in bytes the in memory cache can use.
    • Method Detail

      • onItemEvicted

        protected void onItemEvicted​(@NonNull
                                     Key key,
                                     @Nullable
                                     Resource<?> item)
        Description copied from class: LruCache
        A callback called whenever an item is evicted from the cache. Subclasses can override.
        Overrides:
        onItemEvicted in class LruCache<Key,​Resource<?>>
        Parameters:
        key - The key of the evicted item.
        item - The evicted item.
      • getSize

        protected int getSize​(@Nullable
                              Resource<?> item)
        Description copied from class: LruCache
        Returns the size of a given item, defaulting to one. The units must match those used in the size passed in to the constructor. Subclasses can override this method to return sizes in various units, usually bytes.
        Overrides:
        getSize in class LruCache<Key,​Resource<?>>
        Parameters:
        item - The item to get the size of.
      • trimMemory

        public void trimMemory​(int level)
        Description copied from interface: MemoryCache
        Trim the memory cache to the appropriate level. Typically called on the callback onTrimMemory.
        Specified by:
        trimMemory in interface MemoryCache
        Parameters:
        level - This integer represents a trim level as specified in ComponentCallbacks2.