public final class Util extends Object
Modifier and Type | Method and Description |
---|---|
static void |
assertBackgroundThread()
Throws an
IllegalArgumentException if called on the main thread. |
static void |
assertMainThread()
Throws an
IllegalArgumentException if called on a thread other than the main
thread. |
static boolean |
bothNullOrEqual(Object a,
Object b)
Null-safe equivalent of
a.equals(b) . |
static <T> Queue<T> |
createQueue(int size)
Creates a
Queue of the given size using Glide's preferred implementation. |
static int |
getBitmapByteSize(Bitmap bitmap)
Returns the in memory size of the given
Bitmap in bytes. |
static int |
getBitmapByteSize(int width,
int height,
Bitmap.Config config)
Returns the in memory size of
Bitmap with the given width, height, and
Bitmap.Config . |
static int |
getSize(Bitmap bitmap)
Deprecated.
Use
getBitmapByteSize(android.graphics.Bitmap) instead. Scheduled to be
removed in Glide 4.0. |
static <T> List<T> |
getSnapshot(Collection<T> other)
Returns a copy of the given list that is safe to iterate over and perform actions that may
modify the original list.
|
static boolean |
isOnBackgroundThread()
Returns
true if called on a background thread, false otherwise. |
static boolean |
isOnMainThread()
Returns
true if called on the main thread, false otherwise. |
static boolean |
isValidDimensions(int width,
int height)
Returns true if width and height are both > 0 and/or equal to
Target.SIZE_ORIGINAL . |
static String |
sha256BytesToHex(byte[] bytes)
Returns the hex string of the given byte array representing a SHA256 hash.
|
public static String sha256BytesToHex(byte[] bytes)
@Deprecated public static int getSize(Bitmap bitmap)
getBitmapByteSize(android.graphics.Bitmap)
instead. Scheduled to be
removed in Glide 4.0.public static int getBitmapByteSize(Bitmap bitmap)
Bitmap
in bytes.public static int getBitmapByteSize(int width, int height, Bitmap.Config config)
Bitmap
with the given width, height, and
Bitmap.Config
.public static boolean isValidDimensions(int width, int height)
Target.SIZE_ORIGINAL
.public static void assertMainThread()
IllegalArgumentException
if called on a thread other than the main
thread.public static void assertBackgroundThread()
IllegalArgumentException
if called on the main thread.public static boolean isOnMainThread()
true
if called on the main thread, false
otherwise.public static boolean isOnBackgroundThread()
true
if called on a background thread, false
otherwise.public static <T> Queue<T> createQueue(int size)
Queue
of the given size using Glide's preferred implementation.public static <T> List<T> getSnapshot(Collection<T> other)
See #303 and #375.