app/src/main/java/com/yahala/messenger/LruCache.java
/**
     * @param maxSize the maximum size of the cache before returning. May be -1
     *                to evict even 0-sized elements.
     */
@param maxSize the maximum size of the cache before returning. May be -1
to evict even 0-sized elements.
@param maxSize the maximum size of the cache before returning . May be - 1 to evict even 0 - sized elements .
private void trimToSize(int maxSize) {
        while (true) {
            String key;
            Bitmap value;
            synchronized (this) {
                if (size < 0 || (map.isEmpty() && size != 0)) {
                    throw new IllegalStateException(getClass().getName()
                            + ".sizeOf() is reporting inconsistent results!");
                }
                if (size <= maxSize || map.isEmpty()) {
                    break;
                }
                Map.Entry<String, Bitmap> toEvict = map.entrySet().iterator().next();
                key = toEvict.getKey();
                value = toEvict.getValue();
                map.remove(key);
                size -= safeSizeOf(key, value);
                evictionCount++;
            }
            String[] args = key.split("@");
            if (args.length > 1) {
                ArrayList<String> arr = mapFilters.get(args[0]);
                if (arr != null) {
                    arr.remove(key);
                    if (arr.isEmpty()) {
                        mapFilters.remove(args[1]);
                    }
                }
            }
            entryRemoved(true, key, value, null);
        }
    }
private void trimToSize ( int maxSize ) { while ( true ) { String key ; Bitmap value ; synchronized ( this ) { if ( size < 0 || ( map . isEmpty ( ) && size != 0 ) ) { throw new IllegalStateException ( getClass ( ) . getName ( ) + ".sizeOf() is reporting inconsistent results!" ) ; } if ( size <= maxSize || map . isEmpty ( ) ) { break ; } Map . Entry < String , Bitmap > toEvict = map . entrySet ( ) . iterator ( ) . next ( ) ; key = toEvict . getKey ( ) ; value = toEvict . getValue ( ) ; map . remove ( key ) ; size -= safeSizeOf ( key , value ) ; evictionCount ++ ; } String [ ] args = key . split ( "@" ) ; if ( args . length > 1 ) { ArrayList < String > arr = mapFilters . get ( args [ 0 ] ) ; if ( arr != null ) { arr . remove ( key ) ; if ( arr . isEmpty ( ) ) { mapFilters . remove ( args [ 1 ] ) ; } } } entryRemoved ( true , key , value , null ) ; } }
@param maxSize the maximum size of the cache before returning.
@param maxSize the maximum size of the cache before returning .