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

  • 相关阅读:
    675 对象的引用-浅拷贝-深拷贝
    674 vue3侦听器watch
    673 vue计算属性:缓存,setter和getter
    明明有了promise,为啥还需要async await?
    Js常用数组方法汇总
    一些非常有用的Js单行代码
    Js获取验证码倒计时
    前端截取字符串:JS截取字符串之substring、substr和slice详解
    javascript全局变量与局部变量
    JS实现快速排序算法
  • 原文地址:https://www.cnblogs.com/antble/p/9995268.html
Copyright © 2011-2022 走看看