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

 

转载于:https://www.cnblogs.com/antble/p/9995268.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值