Java 类com.bumptech.glide.signature.ObjectKey 实例源码

项目:science-journal    文件:PictureUtils.java   
public static void loadExperimentImage(Context context, ImageView view, String experimentId,
        String relativeFilePath) {
    if (isDestroyed(context)) {
        if (Log.isLoggable(TAG, Log.ERROR)) {
            Log.e(TAG, "Trying to load image for destroyed context");
        }
        // Nothing we can do, return
        return;
    }

    File file = FileMetadataManager.getExperimentFile(context, experimentId, relativeFilePath);
    // Use last modified time as part of the signature to force a glide cache refresh.
    GlideApp.with(context)
            .load(file.getAbsolutePath())
            .signature(new ObjectKey(file.getPath() + file.lastModified()))
            .fitCenter()
            // caches only the final image, after reducing the resolution
            .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
            .into(view);
}
项目:science-journal    文件:PictureUtils.java   
public static void loadExperimentOverviewImage(ImageView imageView,
        String experimentOverviewFilePath) {
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    Context context = imageView.getContext();
    String fullPath = PictureUtils.getExperimentOverviewFullImagePath(context,
            experimentOverviewFilePath);
    File file = new File(fullPath);
    GlideApp.with(context)
            .load(fullPath)
            // Create a signature based on the last modified time so that cached images will
            // not be used if the underlying file changes. This may happen if the user has
            // picked an experiment photo from the "edit experiment" page because there is only
            // one filename used for that photo.
            .signature(new ObjectKey(file.getPath() + file.lastModified()))
            .into(imageView);
}
项目:S1-Next    文件:EditorDiskCache.java   
public String getKey(String value) {
    String safeKey;
    synchronized (lruCache) {
        safeKey = lruCache.get(value);
    }
    if (safeKey == null) {
        try {
            Key key = new ObjectKey(value);
            MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
            key.updateDiskCacheKey(messageDigest);
            safeKey = Util.sha256BytesToHex(messageDigest.digest());
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        synchronized (lruCache) {
            lruCache.put(value, safeKey);
        }
    }
    return safeKey;
}
项目:GitHub    文件:MediaStoreVideoThumbLoader.java   
@Override
@Nullable
public LoadData<InputStream> buildLoadData(Uri model, int width, int height, Options options) {
  if (MediaStoreUtil.isThumbnailSize(width, height) && isRequestingDefaultFrame(options)) {
    // TODO(nnaze): Tighten down this call to just the dependencies neede by buildVideoFetcher
    return new LoadData<>(new ObjectKey(model), ThumbFetcher.buildVideoFetcher(context, model));
  } else {
    return null;
  }
}
项目:GitHub    文件:MediaStoreImageThumbLoader.java   
@Override
public LoadData<InputStream> buildLoadData(Uri model, int width, int height, Options options) {
  if (MediaStoreUtil.isThumbnailSize(width, height)) {
    return new LoadData<>(new ObjectKey(model), ThumbFetcher.buildImageFetcher(context, model));
  } else {
    return null;
  }
}
项目:GitHub    文件:ResourceCacheKeyTest.java   
@Test
public void testDifferIfSourceKeyDiffers()
    throws UnsupportedEncodingException, NoSuchAlgorithmException {
  mutateAndAssertDifferent(new FactoryMutation() {
    @Override
    public void mutate(Factory factory) {
      factory.sourceKey = new ObjectKey("secondKey");
    }
  });
}
项目:GitHub    文件:ResourceCacheKeyTest.java   
@Test
public void testDiffersIfSignatureDiffers() {
  mutateAndAssertDifferent(new FactoryMutation() {
    @Override
    public void mutate(Factory factory) {
      factory.signature = new ObjectKey("secondSignature");
    }
  });
}
项目:GitHub    文件:MediaStoreVideoThumbLoader.java   
@Override
@Nullable
public LoadData<InputStream> buildLoadData(Uri model, int width, int height, Options options) {
  if (MediaStoreUtil.isThumbnailSize(width, height) && isRequestingDefaultFrame(options)) {
    return new LoadData<>(new ObjectKey(model), ThumbFetcher.buildVideoFetcher(context, model));
  } else {
    return null;
  }
}
项目:GitHub    文件:MediaStoreImageThumbLoader.java   
@Override
public LoadData<InputStream> buildLoadData(Uri model, int width, int height, Options options) {
  if (MediaStoreUtil.isThumbnailSize(width, height)) {
    return new LoadData<>(new ObjectKey(model), ThumbFetcher.buildImageFetcher(context, model));
  } else {
    return null;
  }
}
项目:GitHub    文件:EngineKeyTest.java   
@Test
public void updateDiskCacheKey_throwsException() throws NoSuchAlgorithmException {
  // If this test fails, update testEqualsAndHashcode to use KeyTester including regression tests.
  EngineKey key = new EngineKey(
      "id",
      new ObjectKey("signature"),
      100,
      100,
      Collections.<Class<?>, Transformation<?>>emptyMap(),
      Object.class,
      Object.class,
      new Options());
  expectedException.expect(UnsupportedOperationException.class);
  key.updateDiskCacheKey(MessageDigest.getInstance("SHA-1"));
}
项目:GitHub    文件:DiskLruCacheWrapperTest.java   
@Before
public void setUp() {
  dir = RuntimeEnvironment.application.getCacheDir();
  cache = DiskLruCacheWrapper.create(dir, 10 * 1024 * 1024);
  key = new ObjectKey("test" + Math.random());
  data = new byte[] { 1, 2, 3, 4, 5, 6 };
}
项目:GitHub    文件:MediaStoreFileLoader.java   
@Override
public LoadData<File> buildLoadData(Uri uri, int width, int height, Options options) {
  return new LoadData<>(new ObjectKey(uri), new FilePathFetcher(context, uri));
}
项目:GitHub    文件:ByteBufferFileLoader.java   
@Override
public LoadData<ByteBuffer> buildLoadData(File file, int width, int height,
    Options options) {
  return new LoadData<>(new ObjectKey(file), new ByteBufferFetcher(file));
}
项目:GitHub    文件:AssetUriLoader.java   
@Override
public LoadData<Data> buildLoadData(Uri model, int width, int height,
    Options options) {
  String assetPath = model.toString().substring(ASSET_PREFIX_LENGTH);
  return new LoadData<>(new ObjectKey(model), factory.buildFetcher(assetManager, assetPath));
}
项目:GitHub    文件:DataUrlLoader.java   
@Override
public LoadData<Data> buildLoadData(String model, int width, int height, Options options) {
  return new LoadData<>(new ObjectKey(model), new DataUriFetcher<Data>(model, dataDecoder));
}
项目:GitHub    文件:UnitModelLoader.java   
@Override
public LoadData<Model> buildLoadData(Model model, int width, int height,
    Options options) {
  return new LoadData<>(new ObjectKey(model), new UnitFetcher<>(model));
}
项目:GitHub    文件:FileLoader.java   
@Override
public LoadData<Data> buildLoadData(File model, int width, int height,
    Options options) {
  return new LoadData<>(new ObjectKey(model), new FileFetcher<>(model, fileOpener));
}
项目:GitHub    文件:UriLoader.java   
@Override
public LoadData<Data> buildLoadData(Uri model, int width, int height,
    Options options) {
  return new LoadData<>(new ObjectKey(model), factory.build(model));
}
项目:GitHub    文件:GifFrameLoader.java   
private static Key getFrameSignature() {
  // Some devices seem to have crypto bugs that throw exceptions when you create a new UUID.
  // See #1510.
  return new ObjectKey(Math.random());
}
项目:GitHub    文件:MediaStoreFileLoader.java   
@Override
public LoadData<File> buildLoadData(Uri uri, int width, int height, Options options) {
  return new LoadData<>(new ObjectKey(uri), new FilePathFetcher(context, uri));
}
项目:GitHub    文件:ByteBufferFileLoader.java   
@Override
public LoadData<ByteBuffer> buildLoadData(File file, int width, int height,
    Options options) {
  return new LoadData<>(new ObjectKey(file), new ByteBufferFetcher(file));
}
项目:GitHub    文件:AssetUriLoader.java   
@Override
public LoadData<Data> buildLoadData(Uri model, int width, int height,
    Options options) {
  String assetPath = model.toString().substring(ASSET_PREFIX_LENGTH);
  return new LoadData<>(new ObjectKey(model), factory.buildFetcher(assetManager, assetPath));
}
项目:GitHub    文件:DataUrlLoader.java   
@Override
public LoadData<Data> buildLoadData(String model, int width, int height, Options options) {
  return new LoadData<>(new ObjectKey(model), new DataUriFetcher<>(model, dataDecoder));
}
项目:GitHub    文件:UnitModelLoader.java   
@Override
public LoadData<Model> buildLoadData(Model model, int width, int height,
    Options options) {
  return new LoadData<>(new ObjectKey(model), new UnitFetcher<>(model));
}
项目:GitHub    文件:FileLoader.java   
@Override
public LoadData<Data> buildLoadData(File model, int width, int height,
    Options options) {
  return new LoadData<>(new ObjectKey(model), new FileFetcher<>(model, fileOpener));
}
项目:GitHub    文件:UriLoader.java   
@Override
public LoadData<Data> buildLoadData(Uri model, int width, int height,
    Options options) {
  return new LoadData<>(new ObjectKey(model), factory.build(model));
}
项目:KomaMusic    文件:ArtworkModeLoader.java   
@Nullable
@Override
public LoadData<InputStream> buildLoadData(String category, int width, int height, Options options) {
    return new LoadData<>(new ObjectKey(category), new ArtworkDataFetcher(category));
}
项目:Camera-Roll-Android-App    文件:AlbumItem.java   
public Key getGlideSignature() {
    File file = new File(getPath());
    String lastModified = String.valueOf(file.lastModified());
    return new ObjectKey(lastModified);
}
项目:arctic-icon-request    文件:AppIconLoader.java   
@Nullable
@Override
public LoadData<InputStream> buildLoadData(
    @NonNull AppModel appModel, int width, int height, @NonNull Options options) {
  return new LoadData<>(new ObjectKey(appModel.pkg()), new AppIconDataFetcher(context, appModel));
}
项目:AmazeFileManager    文件:ApkImageModelLoader.java   
@Nullable
@Override
public LoadData<Drawable> buildLoadData(String s, int width, int height, Options options) {
    return new LoadData<>(new ObjectKey(s), new ApkImageDataFetcher(packageManager, s));
}
项目:GitHub    文件:RequestBuilder.java   
/**
 * Returns a request to load the given byte array.
 *
 * <p> Note - by default loads for bytes are not cached in either the memory or the disk cache.
 * </p>
 *
 * @param model the data to load.
 * @see #load(Object)
 */
public RequestBuilder<TranscodeType> load(@Nullable byte[] model) {
  return loadGeneric(model).apply(signatureOf(new ObjectKey(UUID.randomUUID().toString()))
      .diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true /*skipMemoryCache*/));
}
项目:GitHub    文件:RequestBuilder.java   
/**
 * Returns a request to load the given byte array.
 *
 * <p> Note - by default loads for bytes are not cached in either the memory or the disk cache.
 * </p>
 *
 * @param model the data to load.
 * @see #load(Object)
 */
@CheckResult
public RequestBuilder<TranscodeType> load(@Nullable byte[] model) {
  return loadGeneric(model).apply(signatureOf(new ObjectKey(UUID.randomUUID().toString()))
      .diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true /*skipMemoryCache*/));
}