public final class CacheUtil
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
CacheUtil.CachingCounters
Holds the counters used during caching.
|
| Modifier and Type | Method and Description |
|---|---|
static CacheUtil.CachingCounters |
cache(DataSpec dataSpec,
Cache cache,
CacheDataSource dataSource,
byte[] buffer,
PriorityTaskManager priorityTaskManager,
int priority,
CacheUtil.CachingCounters counters)
Caches the data defined by
dataSpec while skipping already cached data. |
static java.lang.String |
generateKey(android.net.Uri uri)
Generates a cache key out of the given
Uri. |
static CacheUtil.CachingCounters |
getCached(DataSpec dataSpec,
Cache cache,
CacheUtil.CachingCounters counters)
Returns already cached and missing bytes in the
cache for the data defined by dataSpec. |
static java.lang.String |
getKey(DataSpec dataSpec)
Returns the
dataSpec.key if not null, otherwise generates a cache key out of dataSpec.uri |
static void |
remove(Cache cache,
java.lang.String key)
Removes all of the data in the
cache pointed by the key. |
public static java.lang.String generateKey(android.net.Uri uri)
Uri.uri - Uri of a content which the requested key is for.public static java.lang.String getKey(DataSpec dataSpec)
dataSpec.key if not null, otherwise generates a cache key out of dataSpec.uridataSpec - Defines a content which the requested key is for.public static CacheUtil.CachingCounters getCached(DataSpec dataSpec, Cache cache, CacheUtil.CachingCounters counters)
cache for the data defined by dataSpec.dataSpec - Defines the data to be checked.cache - A Cache which has the data.counters - The counters to be set. If null a new CacheUtil.CachingCounters is created and
used.CacheUtil.CachingCounters instance.public static CacheUtil.CachingCounters cache(DataSpec dataSpec, Cache cache, CacheDataSource dataSource, byte[] buffer, PriorityTaskManager priorityTaskManager, int priority, CacheUtil.CachingCounters counters) throws java.io.IOException, java.lang.InterruptedException
dataSpec while skipping already cached data.dataSpec - Defines the data to be cached.cache - A Cache to store the data.dataSource - A CacheDataSource that works on the cache.buffer - The buffer to be used while caching.priorityTaskManager - If not null it's used to check whether it is allowed to proceed with
caching.priority - The priority of this task. Used with priorityTaskManager.counters - The counters to be set during caching. If not null its values reset to
zero before using. If null a new CacheUtil.CachingCounters is created and used.CacheUtil.CachingCounters instance.java.io.IOException - If an error occurs reading from the source.java.lang.InterruptedException - If the thread was interrupted.public static void remove(Cache cache, java.lang.String key)
cache pointed by the key.