Package com.bumptech.glide.util
Class Util
- java.lang.Object
-
- com.bumptech.glide.util.Util
-
public final class Util extends java.lang.ObjectA collection of assorted utility classes.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidassertBackgroundThread()Throws anIllegalArgumentExceptionif called on the main thread.static voidassertMainThread()Throws anIllegalArgumentExceptionif called on a thread other than the main thread.static booleanbothModelsNullEquivalentOrEquals(java.lang.Object a, java.lang.Object b)static booleanbothNullOrEqual(java.lang.Object a, java.lang.Object b)Null-safe equivalent ofa.equals(b).static <T> java.util.Queue<T>createQueue(int size)Creates aQueueof the given size using Glide's preferred implementation.static intgetBitmapByteSize(int width, int height, android.graphics.Bitmap.Config config)Returns the in memory size ofBitmapwith the given width, height, andBitmap.Config.static intgetBitmapByteSize(android.graphics.Bitmap bitmap)Returns the in memory size of the givenBitmapin bytes.static intgetBytesPerPixel(android.graphics.Bitmap.Config config)Returns the number of bytes required to store each pixel of aBitmapwith the givenconfig.static intgetSize(android.graphics.Bitmap bitmap)Deprecated.UsegetBitmapByteSize(android.graphics.Bitmap)instead.static <T> java.util.List<T>getSnapshot(java.util.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 inthashCode(java.lang.Object object, int accumulator)static booleanisOnBackgroundThread()Returnstrueif called on a background thread,falseotherwise.static booleanisOnMainThread()Returnstrueif called on the main thread,falseotherwise.static booleanisValidDimension(int dimen)static booleanisValidDimensions(int width, int height)static voidpostOnUiThread(java.lang.Runnable runnable)Posts the givenrunnableto the UI thread using a sharedHandler.static voidremoveCallbacksOnUiThread(java.lang.Runnable runnable)Removes the givenrunnablefrom the UI threads queue if it is still queued.static java.lang.Stringsha256BytesToHex(byte[] bytes)Returns the hex string of the given byte array representing a SHA256 hash.
-
-
-
Method Detail
-
sha256BytesToHex
@NonNull public static java.lang.String sha256BytesToHex(@NonNull byte[] bytes)Returns the hex string of the given byte array representing a SHA256 hash.
-
getSize
@Deprecated public static int getSize(@NonNull android.graphics.Bitmap bitmap)Deprecated.UsegetBitmapByteSize(android.graphics.Bitmap)instead. Scheduled to be removed in Glide 4.0.Returns the allocated byte size of the given bitmap.
-
getBitmapByteSize
public static int getBitmapByteSize(@NonNull android.graphics.Bitmap bitmap)Returns the in memory size of the givenBitmapin bytes.
-
getBitmapByteSize
public static int getBitmapByteSize(int width, int height, @Nullable android.graphics.Bitmap.Config config)Returns the in memory size ofBitmapwith the given width, height, andBitmap.Config.
-
getBytesPerPixel
public static int getBytesPerPixel(@Nullable android.graphics.Bitmap.Config config)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
public static void postOnUiThread(java.lang.Runnable runnable)
Posts the givenrunnableto the UI thread using a sharedHandler.
-
removeCallbacksOnUiThread
public static void removeCallbacksOnUiThread(java.lang.Runnable runnable)
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
@NonNull public static <T> java.util.Queue<T> createQueue(int size)
Creates aQueueof the given size using Glide's preferred implementation.
-
getSnapshot
@NonNull public static <T> java.util.List<T> getSnapshot(@NonNull java.util.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, #375, #322, #2262.
-
bothNullOrEqual
public static boolean bothNullOrEqual(@Nullable java.lang.Object a, @Nullable java.lang.Object b)Null-safe equivalent ofa.equals(b).- See Also:
Objects.equals(java.lang.Object, java.lang.Object)
-
bothModelsNullEquivalentOrEquals
public static boolean bothModelsNullEquivalentOrEquals(@Nullable java.lang.Object a, @Nullable java.lang.Object 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
public static int hashCode(@Nullable java.lang.Object object, int accumulator)
-
hashCode
public static int hashCode(boolean value, int accumulator)
-
hashCode
public static int hashCode(boolean value)
-
-