当前位置: 首页>>代码示例>>Java>>正文


Java DataSource.RESOURCE_DISK_CACHE属性代码示例

本文整理汇总了Java中com.bumptech.glide.load.DataSource.RESOURCE_DISK_CACHE属性的典型用法代码示例。如果您正苦于以下问题:Java DataSource.RESOURCE_DISK_CACHE属性的具体用法?Java DataSource.RESOURCE_DISK_CACHE怎么用?Java DataSource.RESOURCE_DISK_CACHE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.bumptech.glide.load.DataSource的用法示例。


在下文中一共展示了DataSource.RESOURCE_DISK_CACHE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResourceDecoded

@Override
public Resource<Z> onResourceDecoded(Resource<Z> decoded) {
  Class<Z> resourceSubClass = getResourceClass(decoded);
  Transformation<Z> appliedTransformation = null;
  Resource<Z> transformed = decoded;
  if (dataSource != DataSource.RESOURCE_DISK_CACHE) {
    appliedTransformation = decodeHelper.getTransformation(resourceSubClass);
    transformed = appliedTransformation.transform(glideContext, decoded, width, height);
  }
  // TODO: Make this the responsibility of the Transformation.
  if (!decoded.equals(transformed)) {
    decoded.recycle();
  }

  final EncodeStrategy encodeStrategy;
  final ResourceEncoder<Z> encoder;
  if (decodeHelper.isResourceEncoderAvailable(transformed)) {
    encoder = decodeHelper.getResultEncoder(transformed);
    encodeStrategy = encoder.getEncodeStrategy(options);
  } else {
    encoder = null;
    encodeStrategy = EncodeStrategy.NONE;
  }

  Resource<Z> result = transformed;
  boolean isFromAlternateCacheKey = !decodeHelper.isSourceKey(currentSourceKey);
  if (diskCacheStrategy.isResourceCacheable(isFromAlternateCacheKey, dataSource,
      encodeStrategy)) {
    if (encoder == null) {
      throw new Registry.NoResultEncoderAvailableException(transformed.get().getClass());
    }
    final Key key;
    if (encodeStrategy == EncodeStrategy.SOURCE) {
      key = new DataCacheKey(currentSourceKey, signature);
    } else if (encodeStrategy == EncodeStrategy.TRANSFORMED) {
      key = new ResourceCacheKey(currentSourceKey, signature, width, height,
          appliedTransformation, resourceSubClass, options);
    } else {
      throw new IllegalArgumentException("Unknown strategy: " + encodeStrategy);
    }

    LockedResource<Z> lockedResult = LockedResource.obtain(transformed);
    deferredEncodeManager.init(key, encoder, lockedResult);
    result = lockedResult;
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:47,代码来源:DecodeJob.java

示例2: isResourceCacheable

@Override
public boolean isResourceCacheable(boolean isFromAlternateCacheKey, DataSource dataSource,
    EncodeStrategy encodeStrategy) {
  return dataSource != DataSource.RESOURCE_DISK_CACHE && dataSource != DataSource.MEMORY_CACHE;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:DiskCacheStrategy.java

示例3: onResourceDecoded

@Override
public Resource<Z> onResourceDecoded(Resource<Z> decoded) {
  Class<Z> resourceSubClass = getResourceClass(decoded);
  Transformation<Z> appliedTransformation = null;
  Resource<Z> transformed = decoded;
  if (dataSource != DataSource.RESOURCE_DISK_CACHE) {
    appliedTransformation = decodeHelper.getTransformation(resourceSubClass);
    transformed = appliedTransformation.transform(glideContext, decoded, width, height);
  }
  // TODO: Make this the responsibility of the Transformation.
  if (!decoded.equals(transformed)) {
    decoded.recycle();
  }

  final EncodeStrategy encodeStrategy;
  final ResourceEncoder<Z> encoder;
  if (decodeHelper.isResourceEncoderAvailable(transformed)) {
    encoder = decodeHelper.getResultEncoder(transformed);
    encodeStrategy = encoder.getEncodeStrategy(options);
  } else {
    encoder = null;
    encodeStrategy = EncodeStrategy.NONE;
  }

  Resource<Z> result = transformed;
  boolean isFromAlternateCacheKey = !decodeHelper.isSourceKey(currentSourceKey);
  if (diskCacheStrategy.isResourceCacheable(isFromAlternateCacheKey, dataSource,
      encodeStrategy)) {
    if (encoder == null) {
      throw new Registry.NoResultEncoderAvailableException(transformed.get().getClass());
    }
    final Key key;
    if (encodeStrategy == EncodeStrategy.SOURCE) {
      key = new DataCacheKey(currentSourceKey, signature);
    } else if (encodeStrategy == EncodeStrategy.TRANSFORMED) {
      key =
          new ResourceCacheKey(
              decodeHelper.getArrayPool(),
              currentSourceKey,
              signature,
              width,
              height,
              appliedTransformation,
              resourceSubClass,
              options);
    } else {
      throw new IllegalArgumentException("Unknown strategy: " + encodeStrategy);
    }

    LockedResource<Z> lockedResult = LockedResource.obtain(transformed);
    deferredEncodeManager.init(key, encoder, lockedResult);
    result = lockedResult;
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:55,代码来源:DecodeJob.java


注:本文中的com.bumptech.glide.load.DataSource.RESOURCE_DISK_CACHE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。