|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bumptech.glide.Glide
public class Glide
A singleton to present a simple static interface for building requests with BitmapRequestBuilder
and
maintaining an Engine
, BitmapPool
, DiskCache
and
MemoryCache
.
Method Summary | ||
---|---|---|
static
|
buildFileDescriptorModelLoader(Class<T> modelClass,
Context context)
A method to build a ModelLoader for the given model class that produces
ParcelFileDescriptor s using a registered factory. |
|
static
|
buildFileDescriptorModelLoader(T model,
Context context)
A method to build a ModelLoader for the given model class that produces
ParcelFileDescriptor s using a registered factory. |
|
static
|
buildModelLoader(Class<T> modelClass,
Class<Y> resourceClass,
Context context)
Build a ModelLoader for the given model class using registered ModelLoaderFactory s. |
|
static
|
buildModelLoader(T model,
Class<Y> resourceClass,
Context context)
A convenience method to build a ModelLoader for a given model object using registered
ModelLoaderFactory s. |
|
static
|
buildStreamModelLoader(Class<T> modelClass,
Context context)
A method to build a ModelLoader for the given model that produces InputStream s using a registered
factory. |
|
static
|
buildStreamModelLoader(T model,
Context context)
A method to build a ModelLoader for the given model that produces InputStream s using a registered
factory. |
|
static void |
clear(FutureTarget<?> target)
Cancel any pending loads Glide may have for the target and free any resources that may have been loaded into the target so they may be reused. |
|
static void |
clear(Target<?> target)
Cancel any pending loads Glide may have for the target and free any resources (such as Bitmap s) that may
have been loaded for the target so they may be reused. |
|
static void |
clear(View view)
Cancel any pending loads Glide may have for the view and free any resources that may have been loaded for the view. |
|
void |
clearDiskCache()
Clears disk cache. |
|
void |
clearMemory()
Clears as much memory as possible. |
|
static Glide |
get(Context context)
Get the singleton. |
|
BitmapPool |
getBitmapPool()
Returns the BitmapPool used to temporarily store
Bitmap s so they can be reused to avoid garbage collections. |
|
static File |
getPhotoCacheDir(Context context)
Returns a directory with a default name in the private cache directory of the application to use to store retrieved media and thumbnails. |
|
static File |
getPhotoCacheDir(Context context,
String cacheName)
Returns a directory with the given name in the private cache directory of the application to use to store retrieved media and thumbnails. |
|
static boolean |
isSetup()
Deprecated. Use GlideModule instead. Scheduled to be removed in Glide 4.0. |
|
void |
preFillBitmapPool(PreFillType.Builder... bitmapAttributeBuilders)
Pre-fills the BitmapPool using the given sizes. |
|
|
register(Class<T> modelClass,
Class<Y> resourceClass,
ModelLoaderFactory<T,Y> factory)
Use the given factory to build a ModelLoader for models of the given class. |
|
void |
setMemoryCategory(MemoryCategory memoryCategory)
Adjusts Glide's current and maximum memory usage based on the given MemoryCategory . |
|
static void |
setup(GlideBuilder builder)
Deprecated. Use GlideModule instead. Scheduled to be removed in Glide 4.0. |
|
void |
trimMemory(int level)
Clears some memory with the exact amount depending on the given level. |
|
|
unregister(Class<T> modelClass,
Class<Y> resourceClass)
Deprecated. Use register(Class, Class, com.bumptech.glide.load.model.ModelLoaderFactory) to replace
a registered loader rather than simply removing it. |
|
static RequestManager |
with(Activity activity)
Begin a load with Glide that will be tied to the given Activity 's lifecycle and that uses the
given Activity 's default options. |
|
static RequestManager |
with(Context context)
Begin a load with Glide by passing in a context. |
|
static RequestManager |
with(Fragment fragment)
Begin a load with Glide that will be tied to the given Fragment 's lifecycle and that uses
the given Fragment 's default options. |
|
static RequestManager |
with(Fragment fragment)
Begin a load with Glide that will be tied to the given Fragment 's lifecycle and
that uses the given Fragment 's default options. |
|
static RequestManager |
with(FragmentActivity activity)
Begin a load with Glide that will tied to the give FragmentActivity 's lifecycle
and that uses the given FragmentActivity 's default options. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static File getPhotoCacheDir(Context context)
context
- A context.getPhotoCacheDir(android.content.Context, String)
public static File getPhotoCacheDir(Context context, String cacheName)
context
- A context.cacheName
- The name of the subdirectory in which to store the cache.getPhotoCacheDir(android.content.Context)
public static Glide get(Context context)
@Deprecated public static boolean isSetup()
GlideModule
instead. Scheduled to be removed in Glide 4.0.
Glide
singleton has not yet been created and can therefore be setup using
setup(GlideBuilder)
.
setup(GlideBuilder)
@Deprecated public static void setup(GlideBuilder builder)
GlideModule
instead. Scheduled to be removed in Glide 4.0.
Glide
singleton using the given builder. Can be used to set options like cache sizes and
locations.
builder
- The builder.
IllegalArgumentException
- if the Glide singleton has already been created.isSetup()
public BitmapPool getBitmapPool()
BitmapPool
used to temporarily store
Bitmap
s so they can be reused to avoid garbage collections.
Note - Using this pool directly can lead to undefined behavior and strange drawing errors. Any
Bitmap
added to the pool must not be currently in use in any other part of the
application. Any Bitmap
added to the pool must be removed from the pool before it
is added a second time.
Note - To make effective use of the pool, any Bitmap
removed from the pool must
eventually be re-added. Otherwise the pool will eventually empty and will not serve any useful purpose.
The primary reason this object is exposed is for use in custom
ResourceDecoder
s and Transformation
s. Use
outside of these classes is not generally recommended.
public void preFillBitmapPool(PreFillType.Builder... bitmapAttributeBuilders)
BitmapPool
using the given sizes.
Enough Bitmaps are added to completely fill the pool, so most or all of the Bitmaps currently in the pool will be evicted. Bitmaps are allocated according to the weights of the given sizes, where each size gets (weight / prefillWeightSum) percent of the pool to fill.
Note - Pre-filling is done asynchronously using and MessageQueue.IdleHandler
. Any
currently running pre-fill will be cancelled and replaced by a call to this method.
This method should be used with caution, overly aggressive pre-filling is substantially worse than not
pre-filling at all. Pre-filling should only be started in onCreate to avoid constantly clearing and
re-filling the BitmapPool
. Rotation should be carefully
considered as well. It may be worth calling this method only when no saved instance state exists so that
pre-filling only happens when the Activity is first created, rather than on every rotation.
bitmapAttributeBuilders
- The list of
Builders
representing
individual sizes and configurations of Bitmap
s to be pre-filled.public void clearMemory()
ComponentCallbacks.onLowMemory()
,
ComponentCallbacks.onLowMemory()
public void trimMemory(int level)
ComponentCallbacks2.onTrimMemory(int)
public void clearDiskCache()
This method should always be called on a background thread, since it is a blocking call.
public void setMemoryCategory(MemoryCategory memoryCategory)
MemoryCategory
.
The default MemoryCategory
is MemoryCategory.NORMAL
. MemoryCategory.HIGH
increases
Glide's maximum memory usage by up to 50% and MemoryCategory.LOW
decreases Glide's maximum memory
usage by 50%. This method should be used to temporarily increase or decrease memory useage for a single
Activity or part of the app. Use GlideBuilder.setMemoryCache(MemoryCache)
to set a permanent
memory size if you want to change the default.
public static void clear(Target<?> target)
Bitmap
s) that may
have been loaded for the target so they may be reused.
target
- The Target to cancel loads for.public static void clear(FutureTarget<?> target)
target
- The target to cancel loads for.public static void clear(View view)
Note that this will only work if View.setTag(Object)
is not called on this view outside of Glide.
view
- The view to cancel loads and free resources for.
IllegalArgumentException
- if an object other than Glide's metadata is set as the view's tag.clear(Target).
public <T,Y> void register(Class<T> modelClass, Class<Y> resourceClass, ModelLoaderFactory<T,Y> factory)
ModelLoader
for models of the given class. Generally the best use of
this method is to replace one of the default factories or add an implementation for other similar low level
models. Typically the RequestManager.using(com.bumptech.glide.load.model.stream.StreamModelLoader)
or
RequestManager.using(com.bumptech.glide.load.model.file_descriptor.FileDescriptorModelLoader)
syntax is
preferred because it directly links the model with the ModelLoader being used to load it. Any factory replaced
by the given factory will have its ModelLoaderFactory.teardown()
} method called.
Note - If a factory already exists for the given class, it will be replaced. If that factory is not being
used for any other model class, ModelLoaderFactory.teardown()
will be called.
Note - The factory must not be an anonymous inner class of an Activity or another object that cannot be retained statically.
T
- The type of the model.Y
- the type of the resource.modelClass
- The model class.resourceClass
- The resource class the model loader will translate the model type into.factory
- The factory to use.RequestManager.using(com.bumptech.glide.load.model.file_descriptor.FileDescriptorModelLoader)
,
RequestManager.using(com.bumptech.glide.load.model.stream.StreamModelLoader)
@Deprecated public <T,Y> void unregister(Class<T> modelClass, Class<Y> resourceClass)
register(Class, Class, com.bumptech.glide.load.model.ModelLoaderFactory)
to replace
a registered loader rather than simply removing it.
ModelLoaderFactory
registered for the given model and resource classes if one exists. If a
ModelLoaderFactory
is removed, its ModelLoaderFactory.teardown()
} method will be called.
T
- The type of the model.Y
- The type of the resource.modelClass
- The model class.resourceClass
- The resource class.public static <T,Y> ModelLoader<T,Y> buildModelLoader(Class<T> modelClass, Class<Y> resourceClass, Context context)
ModelLoader
for the given model class using registered ModelLoaderFactory
s.
T
- The type of the model.Y
- The type of the resource.modelClass
- The class to get a ModelLoader
for.resourceClass
- The resource class to get a ModelLoader
for.context
- Any context.
ModelLoader
for the given model class.buildModelLoader(Object, Class, Context)
,
buildStreamModelLoader(Class, Context)
,
buildFileDescriptorModelLoader(Class, Context)
public static <T,Y> ModelLoader<T,Y> buildModelLoader(T model, Class<Y> resourceClass, Context context)
ModelLoader
for a given model object using registered
ModelLoaderFactory
s.
T
- The type of the model.Y
- The type of the resource.model
- A non null model object whose class we will get a ModelLoader
for.resourceClass
- The resource class to get a ModelLoader
for.context
- Any context.
ModelLoader
for the given model and resource classes, or null if model is null.buildModelLoader(Class, Class, Context)
public static <T> ModelLoader<T,InputStream> buildStreamModelLoader(Class<T> modelClass, Context context)
ModelLoader
for the given model that produces InputStream
s using a registered
factory.
buildModelLoader(Class, Class, android.content.Context)
public static <T> ModelLoader<T,InputStream> buildStreamModelLoader(T model, Context context)
ModelLoader
for the given model that produces InputStream
s using a registered
factory.
buildModelLoader(Object, Class, Context)
public static <T> ModelLoader<T,ParcelFileDescriptor> buildFileDescriptorModelLoader(Class<T> modelClass, Context context)
ModelLoader
for the given model class that produces
ParcelFileDescriptor
s using a registered factory.
buildModelLoader(Class, Class, android.content.Context)
public static <T> ModelLoader<T,ParcelFileDescriptor> buildFileDescriptorModelLoader(T model, Context context)
ModelLoader
for the given model class that produces
ParcelFileDescriptor
s using a registered factory.
buildModelLoader(Object, Class, android.content.Context)
public static RequestManager with(Context context)
Any requests started using a context will only have the application level options applied and will not be
started or stopped based on lifecycle events. In general, loads should be started at the level the result
will be used in. If the resource will be used in a view in a child fragment,
the load should be started with with(android.app.Fragment)
} using that child fragment. Similarly,
if the resource will be used in a view in the parent fragment, the load should be started with
with(android.app.Fragment)
using the parent fragment. In the same vein, if the resource will be used
in a view in an activity, the load should be started with with(android.app.Activity)
}.
This method is appropriate for resources that will be used outside of the normal fragment or activity lifecycle (For example in services, or for notification thumbnails).
context
- Any context, will not be retained.
with(android.app.Activity)
,
with(android.app.Fragment)
,
with(android.support.v4.app.Fragment)
,
with(android.support.v4.app.FragmentActivity)
public static RequestManager with(Activity activity)
Activity
's lifecycle and that uses the
given Activity
's default options.
activity
- The activity to use.
public static RequestManager with(FragmentActivity activity)
FragmentActivity
's lifecycle
and that uses the given FragmentActivity
's default options.
activity
- The activity to use.
public static RequestManager with(Fragment fragment)
Fragment
's lifecycle and that uses
the given Fragment
's default options.
fragment
- The fragment to use.
public static RequestManager with(Fragment fragment)
Fragment
's lifecycle and
that uses the given Fragment
's default options.
fragment
- The fragment to use.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |