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()); }
@Override public LoadData<Data> buildLoadData(@NonNull Uri model, int width, int height, @NonNull Options options) { String assetPath = model.toString().substring(ASSET_PREFIX_LENGTH); return new LoadData<>(new ObjectKey(model), factory.buildFetcher(assetManager, assetPath)); }
@Override public LoadData<Data> buildLoadData(@NonNull Uri model, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(model), factory.build(model)); }
@Override public LoadData<Data> buildLoadData(@NonNull Model model, int width, int height, @NonNull Options options) { return new LoadData<>( new ObjectKey(model), new DataUriFetcher<>(model.toString(), dataDecoder)); }
@Override public LoadData<ByteBuffer> buildLoadData(@NonNull File file, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(file), new ByteBufferFetcher(file)); }
@Override public LoadData<Data> buildLoadData( @NonNull byte[] model, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(model), new Fetcher<>(model, converter)); }
@Override public LoadData<Data> buildLoadData(@NonNull File model, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(model), new FileFetcher<>(model, fileOpener)); }
@Override public LoadData<Model> buildLoadData(@NonNull Model model, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(model), new UnitFetcher<>(model)); }
@Override public LoadData<File> buildLoadData(@NonNull Uri uri, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(uri), new FilePathFetcher(context, uri)); }
@Override public LoadData<InputStream> buildLoadData(@NonNull Uri model, int width, int height, @NonNull Options options) { if (MediaStoreUtil.isThumbnailSize(width, height)) { return new LoadData<>(new ObjectKey(model), ThumbFetcher.buildImageFetcher(context, model)); } else { return null; } }
@Override @Nullable public LoadData<InputStream> buildLoadData(@NonNull Uri model, int width, int height, @NonNull Options options) { if (MediaStoreUtil.isThumbnailSize(width, height) && isRequestingDefaultFrame(options)) { return new LoadData<>(new ObjectKey(model), ThumbFetcher.buildVideoFetcher(context, model)); } else { return null; } }
@NonNull private static Key obtainVersionSignature(@NonNull Context context) { PackageInfo packageInfo = getPackageInfo(context); String versionCode = getVersionCode(packageInfo); return new ObjectKey(versionCode); }
@Test public void testEqualsHashCodeAndDigest() throws NoSuchAlgorithmException { Object object = new Object(); keyTester .addEquivalenceGroup(new ObjectKey(object), new ObjectKey(object)) .addEquivalenceGroup(new ObjectKey(new Object())) .addEquivalenceGroup(new ObjectKey("test"), new ObjectKey("test")) .addRegressionTest( new ObjectKey("test"), "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08") .test(); } }
@android.support.annotation.Nullable @Override public LoadData<InputStream> buildLoadData(@NonNull Object o, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(o), new Fetcher()); }
@Override public LoadData<DataT> buildLoadData(@NonNull ModelT modelT, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(modelT), new MockDataFetcher<>(data)); }
@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 }; }
@Test public void updateDiskCacheKey_throwsException() throws NoSuchAlgorithmException { // If this test fails, update testEqualsAndHashcode to use KeyTester including regression tests. final EngineKey key = new EngineKey( "id", new ObjectKey("signature"), 100, 100, Collections.<Class<?>, Transformation<?>>emptyMap(), Object.class, Object.class, new Options()); assertThrows( UnsupportedOperationException.class, new ThrowingRunnable() { @Override public void run() throws NoSuchAlgorithmException { key.updateDiskCacheKey(MessageDigest.getInstance("SHA-1")); } }); }
new ResourceCacheKey( arrayPool, new ObjectKey("source"), new ObjectKey("signature"), 100, 100, new ResourceCacheKey( arrayPool, new ObjectKey("source"), new ObjectKey("signature"), 100, 100, new ResourceCacheKey( arrayPool, new ObjectKey("otherSource"), new ObjectKey("signature"), 100, 100, new ResourceCacheKey( arrayPool, new ObjectKey("source"), new ObjectKey("otherSignature"), 100, 100, new ResourceCacheKey(
new EngineKey( "id", new ObjectKey("signature"), 100, 100, new EngineKey( "id", new ObjectKey("signature"), 100, 100, new EngineKey( "otherId", new ObjectKey("signature"), 100, 100, new EngineKey( "id", new ObjectKey("otherSignature"), 100, 100, new EngineKey( "id", new ObjectKey("signature"), 200, 100,
@Test public void testKeyForSignatureIsTheSameAcrossCallsInTheSamePackage() throws NoSuchAlgorithmException, UnsupportedEncodingException { keyTester .addEquivalenceGroup( ApplicationVersionSignature.obtain(context), ApplicationVersionSignature.obtain(context)) .addEquivalenceGroup(new ObjectKey("test")) .addRegressionTest( ApplicationVersionSignature.obtain(context), "5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9") .test(); }