ProducerContext 的作用
主要是用来将上下文信息传递给 Producer;可以具体看看代码,可以发现 context 内部包含很多逻辑。
复制代码
public interface ProducerContext {
@StringDef({
ExtraKeys.ORIGIN,
ExtraKeys.ORIGIN_SUBCATEGORY,
ExtraKeys.NORMALIZED_URI,
ExtraKeys.SOURCE_URI,
ExtraKeys.ENCODED_WIDTH,
ExtraKeys.ENCODED_HEIGHT,
ExtraKeys.ENCODED_SIZE,
ExtraKeys.MULTIPLEX_BITMAP_COUNT,
ExtraKeys.MULTIPLEX_ENCODED_COUNT,
})
@interface ExtraKeys {
String ORIGIN = “origin”;
String ORIGIN_SUBCATEGORY = “origin_sub”;
String SOURCE_URI = “uri_source”;
String NORMALIZED_URI = “uri_norm”;
String ENCODED_WIDTH = “encoded_width”;
String ENCODED_HEIGHT = “encoded_height”;
String ENCODED_SIZE = “encoded_size”;
/* number of deduped request in BitmapMemoryCacheKeyMultiplexProducer /
String MULTIPLEX_BITMAP_COUNT = “multiplex_bmp_cnt”;
/ number of deduped request in EncodedCacheKeyMultiplexProducer */
String MULTIPLEX_ENCODED_COUNT = “multiplex_enc_cnt”;
}
/** @return image request that is being executed */
ImageRequest getImageRequest();
/** @return id of this request */
String getId();
/** @return optional id of the UI component requesting the image */
@Nullable
String getUiComponentId();
/** @return ProducerListener2 for producer’s events */
ProducerListener2 getProducerListener();
/** @return the {@link Object} that indicates the caller’s context */
Object getCallerContext();
/** @return the lowest permitted {@link ImageRequest.RequestLevel} */
ImageRequest.RequestLevel getLowestPermittedRequestLevel();
/** @return true if the request is a prefetch, false otherwise. */
boolean isPrefetch();
/** @return priority of the request. */
Priority getPriority();
/** @return true if request’s owner expects intermediate results */
boolean isIntermediateResultExpected();
/**
- Adds callbacks to the set of callbacks that are executed at various points during the
- processing of a request.
- @param callbacks callbacks to be executed
*/
void addCallbacks(ProducerContextCallbacks callbacks);
ImagePipelineConfig getImagePipelineConfig();
EncodedImageOrigin getEncodedImageOrigin();
void setEncodedImageOrigin(EncodedImageOrigin encodedImageOrigin);
void setExtra(@ExtraKeys String key, @Nullable E value);
void putExtras(@Nullable Map<String, ?> extras);
@Nullable
E getExtra(String key);
@Nullable
E getExtra(String key, @Nullable E valueIfNotFound);
Map<String, Object> getExtras();
/** Helper to set {@link ExtraKeys#ORIGIN} and {@link ExtraKeys#ORIGIN_SUBCATEGORY} */
void putOriginExtra(@Nullable String origin, @Nullable String subcategory);
/** Helper to set {@link ExtraKeys#ORIGIN} */
void putOriginExtra(@Nullable String origin);
}
USB Microphone https://www.soft-voice.com/
Wooden Speakers https://www.zeshuiplatform.com/
亚马逊测评 www.yisuping.cn
深圳网站建设www.sz886.com