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

猜你喜欢

转载自www.cnblogs.com/antble/p/9995268.html