本文整理汇总了Java中com.bumptech.glide.signature.ObjectKey类的典型用法代码示例。如果您正苦于以下问题:Java ObjectKey类的具体用法?Java ObjectKey怎么用?Java ObjectKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectKey类属于com.bumptech.glide.signature包,在下文中一共展示了ObjectKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadExperimentImage
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
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);
}
示例2: loadExperimentOverviewImage
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
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);
}
示例3: getKey
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
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;
}
示例4: buildLoadData
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@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;
}
}
示例5: buildLoadData
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@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;
}
}
示例6: testDifferIfSourceKeyDiffers
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@Test
public void testDifferIfSourceKeyDiffers()
throws UnsupportedEncodingException, NoSuchAlgorithmException {
mutateAndAssertDifferent(new FactoryMutation() {
@Override
public void mutate(Factory factory) {
factory.sourceKey = new ObjectKey("secondKey");
}
});
}
示例7: testDiffersIfSignatureDiffers
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@Test
public void testDiffersIfSignatureDiffers() {
mutateAndAssertDifferent(new FactoryMutation() {
@Override
public void mutate(Factory factory) {
factory.signature = new ObjectKey("secondSignature");
}
});
}
示例8: buildLoadData
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@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;
}
}
示例9: updateDiskCacheKey_throwsException
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@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"));
}
示例10: setUp
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@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 };
}
示例11: buildLoadData
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@Override
public LoadData<File> buildLoadData(Uri uri, int width, int height, Options options) {
return new LoadData<>(new ObjectKey(uri), new FilePathFetcher(context, uri));
}
示例12: buildLoadData
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@Override
public LoadData<ByteBuffer> buildLoadData(File file, int width, int height,
Options options) {
return new LoadData<>(new ObjectKey(file), new ByteBufferFetcher(file));
}
示例13: buildLoadData
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@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));
}
示例14: buildLoadData
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@Override
public LoadData<Data> buildLoadData(String model, int width, int height, Options options) {
return new LoadData<>(new ObjectKey(model), new DataUriFetcher<Data>(model, dataDecoder));
}
示例15: buildLoadData
import com.bumptech.glide.signature.ObjectKey; //导入依赖的package包/类
@Override
public LoadData<Model> buildLoadData(Model model, int width, int height,
Options options) {
return new LoadData<>(new ObjectKey(model), new UnitFetcher<>(model));
}