use of com.bumptech.glide.load.Key in project glide by bumptech.
the class MultiModelLoader method buildLoadData.
@Override
public LoadData<Data> buildLoadData(Model model, int width, int height, Options options) {
Key sourceKey = null;
int size = modelLoaders.size();
List<DataFetcher<Data>> fetchers = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
ModelLoader<Model, Data> modelLoader = modelLoaders.get(i);
if (modelLoader.handles(model)) {
LoadData<Data> loadData = modelLoader.buildLoadData(model, width, height, options);
if (loadData != null) {
sourceKey = loadData.sourceKey;
fetchers.add(loadData.fetcher);
}
}
}
return !fetchers.isEmpty() ? new LoadData<>(sourceKey, new MultiFetcher<>(fetchers, exceptionListPool)) : null;
}
use of com.bumptech.glide.load.Key in project glide by bumptech.
the class EngineKeyTest method testDiffersIfSignatureDiffers.
@Test
public void testDiffersIfSignatureDiffers() throws UnsupportedEncodingException, NoSuchAlgorithmException {
EngineKey first = harness.build();
Key signature = mock(Key.class);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
MessageDigest digest = (MessageDigest) invocationOnMock.getArguments()[0];
digest.update("signature".getBytes("UTF-8"));
return null;
}
}).when(signature).updateDiskCacheKey(any(MessageDigest.class));
harness.signature = signature;
EngineKey second = harness.build();
KeyAssertions.assertDifferent(first, second, false);
}
use of com.bumptech.glide.load.Key in project glide by bumptech.
the class RecyclerAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ListViewHolder viewHolder, int position) {
MediaStoreData current = data.get(position);
Key signature = new MediaStoreSignature(current.mimeType, current.dateModified, current.orientation);
requestBuilder.clone().apply(signatureOf(signature)).load(current.uri).into(viewHolder.image);
}
Aggregations