Package com.bumptech.glide.util
Class Util
java.lang.Object
com.bumptech.glide.util.Util
A collection of assorted utility classes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidThrows anIllegalArgumentExceptionif called on the main thread.static voidThrows anIllegalArgumentExceptionif called on a thread other than the main thread.static booleanstatic booleanstatic booleanbothNullOrEqual(Object a, Object b) Null-safe equivalent ofa.equals(b).static <T> Queue<T>createQueue(int size) Creates aQueueof the given size using Glide's preferred implementation.static intgetBitmapByteSize(int width, int height, Bitmap.Config config) Returns the in memory size ofBitmapwith the given width, height, andBitmap.Config.static intgetBitmapByteSize(Bitmap bitmap) Returns the in memory size of the givenBitmapin bytes.static intgetBytesPerPixel(Bitmap.Config config) Returns the number of bytes required to store each pixel of aBitmapwith the givenconfig.static intDeprecated.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 inthashCode(boolean value) static inthashCode(boolean value, int accumulator) static inthashCode(float value) static inthashCode(float value, int accumulator) static inthashCode(int value) static inthashCode(int value, int accumulator) static intstatic booleanReturnstrueif called on a background thread,falseotherwise.static booleanReturnstrueif called on the main thread,falseotherwise.static booleanisValidDimension(int dimen) static booleanisValidDimensions(int width, int height) static voidpostOnUiThread(Runnable runnable) Posts the givenrunnableto the UI thread using a sharedHandler.static voidremoveCallbacksOnUiThread(Runnable runnable) Removes the givenrunnablefrom the UI threads queue if it is still queued.static Stringsha256BytesToHex(byte[] bytes) Returns the hex string of the given byte array representing a SHA256 hash.
-
Method Details
-
sha256BytesToHex
Returns the hex string of the given byte array representing a SHA256 hash. -
getSize
Deprecated.UsegetBitmapByteSize(android.graphics.Bitmap)instead. Scheduled to be removed in Glide 4.0.Returns the allocated byte size of the given bitmap. -
getBitmapByteSize
Returns the in memory size of the givenBitmapin bytes. -
getBitmapByteSize
Returns the in memory size ofBitmapwith the given width, height, andBitmap.Config. -
getBytesPerPixel
Returns the number of bytes required to store each pixel of aBitmapwith the givenconfig.Defaults to
Bitmap.Config.ARGB_8888ifconfigisnull. -
isValidDimensions
public static boolean isValidDimensions(int width, int height) -
isValidDimension
public static boolean isValidDimension(int dimen) -
postOnUiThread
Posts the givenrunnableto the UI thread using a sharedHandler. -
removeCallbacksOnUiThread
Removes the givenrunnablefrom the UI threads queue if it is still queued. -
assertMainThread
public static void assertMainThread()Throws anIllegalArgumentExceptionif called on a thread other than the main thread. -
assertBackgroundThread
public static void assertBackgroundThread()Throws anIllegalArgumentExceptionif called on the main thread. -
isOnMainThread
public static boolean isOnMainThread()Returnstrueif called on the main thread,falseotherwise. -
isOnBackgroundThread
public static boolean isOnBackgroundThread()Returnstrueif called on a background thread,falseotherwise. -
createQueue
Creates aQueueof the given size using Glide's preferred implementation. -
getSnapshot
Returns a copy of the given list that is safe to iterate over and perform actions that may modify the original list.See #303, #375, #322, #2262.
-
bothNullOrEqual
Null-safe equivalent ofa.equals(b). -
bothModelsNullEquivalentOrEquals
-
bothBaseRequestOptionsNullEquivalentOrEquals
public static boolean bothBaseRequestOptionsNullEquivalentOrEquals(@Nullable BaseRequestOptions<?> a, @Nullable BaseRequestOptions<?> b) -
hashCode
public static int hashCode(int value) -
hashCode
public static int hashCode(int value, int accumulator) -
hashCode
public static int hashCode(float value) -
hashCode
public static int hashCode(float value, int accumulator) -
hashCode
-
hashCode
public static int hashCode(boolean value, int accumulator) -
hashCode
public static int hashCode(boolean value)
-
getBitmapByteSize(android.graphics.Bitmap)instead.