本文整理汇总了Java中com.bumptech.glide.load.ResourceEncoder类的典型用法代码示例。如果您正苦于以下问题:Java ResourceEncoder类的具体用法?Java ResourceEncoder怎么用?Java ResourceEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceEncoder类属于com.bumptech.glide.load包,在下文中一共展示了ResourceEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSizeReady
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
@Override
public void onSizeReady(int width, int height) {
if (isCancelled) {
return;
}
width = Math.round(sizeMultiplier * width);
height = Math.round(sizeMultiplier * height);
ResourceDecoder<InputStream, Z> cacheDecoder = loadProvider.getCacheDecoder();
ResourceDecoder<T, Z> decoder = loadProvider.getSourceDecoder();
ResourceEncoder <Z> encoder = loadProvider.getEncoder();
ResourceTranscoder<Z, R> transcoder = loadProvider.getTranscoder();
ModelLoader<A, T> modelLoader = loadProvider.getModelLoader();
final String id = modelLoader.getId(model);
final DataFetcher<T> dataFetcher = modelLoader.getResourceFetcher(model, width, height);
loadedFromMemoryCache = true;
loadStatus = engine.load(id, width, height, cacheDecoder, dataFetcher, decoder, transformation,
encoder, transcoder, priority, isMemoryCacheable, this);
loadedFromMemoryCache = resource != null;
}
示例2: get
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Nullable
public synchronized <Z> ResourceEncoder<Z> get(Class<Z> resourceClass) {
int size = encoders.size();
for (int i = 0; i < size; i++) {
Entry<?> entry = encoders.get(i);
if (entry.handles(resourceClass)) {
return (ResourceEncoder<Z>) entry.encoder;
}
}
// TODO: throw an exception here?
return null;
}
示例3: getResultEncoder
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
public <X> ResourceEncoder<X> getResultEncoder(Resource<X> resource)
throws NoResultEncoderAvailableException {
ResourceEncoder<X> resourceEncoder = resourceEncoderRegistry.get(resource.getResourceClass());
if (resourceEncoder != null) {
return resourceEncoder;
}
throw new NoResultEncoderAvailableException(resource.getResourceClass());
}
示例4: SourceResourceRunner
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
public SourceResourceRunner(Key key, int width, int height, DataFetcher<T> dataFetcher,
ResourceDecoder<T, Z> decoder, Transformation<Z> transformation, ResourceEncoder<Z> encoder,
ResourceTranscoder<Z, R> transcoder, DiskCache diskCache, Priority priority, ResourceCallback cb) {
this.key = key;
this.width = width;
this.height = height;
this.fetcher = dataFetcher;
this.decoder = decoder;
this.transformation = transformation;
this.encoder = encoder;
this.transcoder = transcoder;
this.diskCache = diskCache;
this.priority = priority;
this.cb = cb;
}
示例5: EngineKey
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
public EngineKey(String id, int width, int height, ResourceDecoder cacheDecoder, ResourceDecoder decoder,
Transformation transformation, ResourceEncoder encoder, ResourceTranscoder transcoder) {
this.id = id;
this.width = width;
this.height = height;
this.cacheDecoder = cacheDecoder;
this.decoder = decoder;
this.transformation = transformation;
this.encoder = encoder;
this.transcoder = transcoder;
}
示例6: load
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
/**
*
* @param id A unique id for the model, dimensions, cache decoder, decoder, and encoder
* @param cacheDecoder
* @param fetcher
* @param decoder
* @param encoder
* @param transcoder
* @param priority
* @param <T> The type of data the resource will be decoded from.
* @param <Z> The type of the resource that will be decoded.
* @param <R> The type of the resource that will be transcoded from the decoded resource.
*/
public <T, Z, R> LoadStatus load(String id, int width, int height, ResourceDecoder<InputStream, Z> cacheDecoder,
DataFetcher<T> fetcher, ResourceDecoder<T, Z> decoder, Transformation<Z> transformation,
ResourceEncoder<Z> encoder, ResourceTranscoder<Z, R> transcoder, Priority priority,
boolean isMemoryCacheable, ResourceCallback cb) {
Key key = keyFactory.buildKey(id, width, height, cacheDecoder, decoder, transformation, encoder, transcoder);
Resource cached = cache.get(key);
if (cached != null) {
cached.acquire(1);
cb.onResourceReady(cached);
return null;
}
ResourceRunner current = runners.get(key);
if (current != null) {
EngineJob job = current.getJob();
job.addCallback(cb);
return new LoadStatus(cb, job);
}
ResourceRunner<Z, R> runner = factory.build(key, width, height, cacheDecoder, fetcher, decoder, transformation,
encoder, transcoder, priority, isMemoryCacheable, this);
runner.getJob().addCallback(cb);
runners.put(key, runner);
runner.queue();
return new LoadStatus(cb, runner.getJob());
}
示例7: build
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
@Override
public <T, Z, R> ResourceRunner<Z, R> build(Key key, int width, int height,
ResourceDecoder<InputStream, Z> cacheDecoder, DataFetcher<T> fetcher, ResourceDecoder<T, Z> decoder,
Transformation<Z> transformation, ResourceEncoder<Z> encoder, ResourceTranscoder<Z, R> transcoder,
Priority priority, boolean isMemoryCacheable, EngineJobListener listener) {
EngineJob engineJob = new EngineJob(key, memoryCache, mainHandler, isMemoryCacheable, listener);
SourceResourceRunner<T, Z, R> sourceRunner = new SourceResourceRunner<T, Z, R>(key, width, height, fetcher,
decoder, transformation, encoder, transcoder, diskCache, priority, engineJob);
return new ResourceRunner<Z, R>(key, width, height, diskCache, cacheDecoder, transcoder, sourceRunner, service,
bgHandler, engineJob);
}
示例8: getEncoder
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
@Override
public ResourceEncoder<Z> getEncoder() {
if (encoder != null) {
return encoder;
} else {
return parent.getEncoder();
}
}
示例9: BitmapDrawableEncoder
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
public BitmapDrawableEncoder(BitmapPool bitmapPool, ResourceEncoder<Bitmap> encoder) {
this.bitmapPool = bitmapPool;
this.encoder = encoder;
}
示例10: getResultEncoder
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
<Z> ResourceEncoder<Z> getResultEncoder(Resource<Z> resource) {
return glideContext.getRegistry().getResultEncoder(resource);
}
示例11: onResourceDecoded
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
@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;
}
示例12: init
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
<X> void init(Key key, ResourceEncoder<X> encoder, LockedResource<X> toEncode) {
this.key = key;
this.encoder = (ResourceEncoder<Z>) encoder;
this.toEncode = (LockedResource<Z>) toEncode;
}
示例13: add
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
public synchronized <Z> void add(Class<Z> resourceClass, ResourceEncoder<Z> encoder) {
encoders.add(new Entry<>(resourceClass, encoder));
}
示例14: Entry
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
Entry(Class<T> resourceClass, ResourceEncoder<T> encoder) {
this.resourceClass = resourceClass;
this.encoder = encoder;
}
示例15: register
import com.bumptech.glide.load.ResourceEncoder; //导入依赖的package包/类
public <TResource> Registry register(Class<TResource> resourceClass,
ResourceEncoder<TResource> encoder) {
resourceEncoderRegistry.add(resourceClass, encoder);
return this;
}