com.bumptech.glide.util
Class Util

java.lang.Object
  extended by com.bumptech.glide.util.Util

public final class Util
extends Object

A collection of assorted utility classes.


Method Summary
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
<T> Queue<T>
createQueue(int size)
          Returns 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 the main 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 sha1BytesToHex(byte[] bytes)
          Returns the hex string of the given byte array representing a SHA1 hash.
static String sha256BytesToHex(byte[] bytes)
          Returns the hex string of the given byte array representing a SHA256 hash.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sha256BytesToHex

public static String sha256BytesToHex(byte[] bytes)
Returns the hex string of the given byte array representing a SHA256 hash.


sha1BytesToHex

public static String sha1BytesToHex(byte[] bytes)
Returns the hex string of the given byte array representing a SHA1 hash.


getSize

@Deprecated
public static int getSize(Bitmap bitmap)
Deprecated. Use getBitmapByteSize(android.graphics.Bitmap) instead. Scheduled to be removed in Glide 4.0.

Returns the allocated byte size of the given bitmap.

See Also:
getBitmapByteSize(android.graphics.Bitmap)

getBitmapByteSize

public static int getBitmapByteSize(Bitmap bitmap)
Returns the in memory size of the given Bitmap in bytes.


getBitmapByteSize

public 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.


isValidDimensions

public static boolean isValidDimensions(int width,
                                        int height)
Returns true if width and height are both > 0 and/or equal to Target.SIZE_ORIGINAL.


assertMainThread

public static void assertMainThread()
Throws an IllegalArgumentException if called on a thread other than the main thread.


assertBackgroundThread

public static void assertBackgroundThread()
Throws an IllegalArgumentException if called on the main thread.


isOnMainThread

public static boolean isOnMainThread()
Returns true if called on the main thread, false otherwise.


isOnBackgroundThread

public static boolean isOnBackgroundThread()
Returns true if called on the main thread, false otherwise.


createQueue

public static <T> Queue<T> createQueue(int size)
Returns a Queue of the given size using Glide's preferred implementation.


getSnapshot

public 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.

See #303 and #375.