zoukankan      html  css  js  c++  java
  • Picasso遇到的坑

    Heyoo:

    1、通过priority设置低、中、高三级优先队列。

    2、Picasso缓存机制采用LruCache,底层为 LinkedHashMap()。

        有四个因素影响key值。分别是:

     1 //Utils.createKey() 方法:
     2 public static String createKey(Request data, StringBuilder builder) {
     3   if (data.stableKey != null) {    //创建请求时我们主动指定的一个 key,默认为空
     4     builder.ensureCapacity(data.stableKey.length() + KEY_PADDING);
     5     builder.append(data.stableKey);
     6   } else if (data.uri != null) {    //uri
     7     String path = data.uri.toString();
     8     builder.ensureCapacity(path.length() + KEY_PADDING);
     9     builder.append(path);
    10   } else {
    11     builder.ensureCapacity(KEY_PADDING);
    12     builder.append(data.resourceId);
    13   }
    14   builder.append(KEY_SEPARATOR);
    15 
    16   if (data.rotationDegrees != 0) {    //旋转角度
    17     builder.append("rotation:").append(data.rotationDegrees);
    18     if (data.hasRotationPivot) {
    19       builder.append('@').append(data.rotationPivotX).append('x').append(data.rotationPivotY);
    20     }
    21     builder.append(KEY_SEPARATOR);
    22   }
    23   if (data.hasSize()) {    //修改尺寸
    24     builder.append("resize:").append(data.targetWidth).append('x').append(data.targetHeight);
    25     builder.append(KEY_SEPARATOR);
    26   }
    27   if (data.centerCrop) {    //裁剪
    28     builder.append("centerCrop:").append(data.centerCropGravity).append(KEY_SEPARATOR);
    29   } else if (data.centerInside) {
    30     builder.append("centerInside").append(KEY_SEPARATOR);
    31   }
    32 
    33   if (data.transformations != null) {    //变换
    34     //noinspection ForLoopReplaceableByForEach
    35     for (int i = 0, count = data.transformations.size(); i < count; i++) {
    36       builder.append(data.transformations.get(i).key());
    37       builder.append(KEY_SEPARATOR);
    38     }
    39   }
    40 
    41   return builder.toString();
    42 }

      (Glide不会这样,未了解有待考证)

    3、fit、centerCrop、transform

  • 相关阅读:
    [姿势] 关于Ubuntu16.04安装前后
    [题解] poj 1716 Integer Intervals (差分约束+spfa)
    [题解] hdu 2433 Travel (BFS)
    [题解] poj 3169 Layout (差分约束+bellmanford)
    [题解] poj 3660 Cow Contest (floyd)
    [题解] hdu 1142 A Walk Through the Forest (dijkstra最短路 + 记忆化搜索)
    [题解] poj 1724 ROADS (dijkstra最短路+A*搜索)
    [BZOJ1491][NOI2007]社交网络 floyd
    [BZOJ2064]分裂 状压dp
    [BZOJ3585]mex 主席树
  • 原文地址:https://www.cnblogs.com/antble/p/9995268.html
Copyright © 2011-2022 走看看