Java Code Examples for java.util.NavigableMap#ceilingKey()

The following examples show how to use java.util.NavigableMap#ceilingKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SizeConfigStrategy.java    From giffun with Apache License 2.0 6 votes vote down vote up
private Key findBestKey(Key key, int size, Bitmap.Config config) {
    Key result = key;
    for (Bitmap.Config possibleConfig : getInConfigs(config)) {
        NavigableMap<Integer, Integer> sizesForPossibleConfig = getSizesForConfig(possibleConfig);
        Integer possibleSize = sizesForPossibleConfig.ceilingKey(size);
        if (possibleSize != null && possibleSize <= size * MAX_SIZE_MULTIPLE) {
            if (possibleSize != size
                    || (possibleConfig == null ? config != null : !possibleConfig.equals(config))) {
                keyPool.offer(key);
                result = keyPool.get(possibleSize, possibleConfig);
            }
            break;
        }
    }
    return result;
}
 
Example 2
Source File: SizeConfigStrategy.java    From GlideBitmapPool with Apache License 2.0 6 votes vote down vote up
private Key findBestKey(int size, Bitmap.Config config) {
    Key result = keyPool.get(size, config);
    for (Bitmap.Config possibleConfig : getInConfigs(config)) {
        NavigableMap<Integer, Integer> sizesForPossibleConfig = getSizesForConfig(possibleConfig);
        Integer possibleSize = sizesForPossibleConfig.ceilingKey(size);
        if (possibleSize != null && possibleSize <= size * MAX_SIZE_MULTIPLE) {
            if (possibleSize != size
                    || (possibleConfig == null ? config != null : !possibleConfig.equals(config))) {
                keyPool.offer(result);
                result = keyPool.get(possibleSize, possibleConfig);
            }
            break;
        }
    }
    return result;
}
 
Example 3
Source File: SizeConfigStrategy.java    From sketch with Apache License 2.0 6 votes vote down vote up
private Key findBestKey(Key key, int size, Bitmap.Config config) {
    Key result = key;
    for (Bitmap.Config possibleConfig : getInConfigs(config)) {
        NavigableMap<Integer, Integer> sizesForPossibleConfig = getSizesForConfig(possibleConfig);
        Integer possibleSize = sizesForPossibleConfig.ceilingKey(size);
        if (possibleSize != null && possibleSize <= size * MAX_SIZE_MULTIPLE) {
            if (possibleSize != size
                    || (possibleConfig == null ? config != null : !possibleConfig.equals(config))) {
                keyPool.offer(key);
                result = keyPool.get(possibleSize, possibleConfig);
            }
            break;
        }
    }
    return result;
}