-
public final class UtilA collection of assorted utility classes.
-
-
Method Summary
Modifier and Type Method Description static Stringsha256BytesToHex(@NonNull() Array<byte> bytes)Returns the hex string of the given byte array representing a SHA256 hash. static intgetSize(@NonNull() Bitmap bitmap)Returns the allocated byte size of the given bitmap. static intgetBitmapByteSize(@NonNull() Bitmap bitmap)Returns the in memory size of the given Bitmap in bytes. static intgetBitmapByteSize(int width, int height, @Nullable() Bitmap.Config config)Returns the in memory size of Bitmap with the given width, height, and Bitmap.Config. static booleanisValidDimensions(int width, int height)Returns true if width and height are both > 0 and/or equal to SIZE_ORIGINAL. static voidpostOnUiThread(Runnable runnable)Posts the given {@code runnable}to the UI thread using a shared Handler.static voidremoveCallbacksOnUiThread(Runnable runnable)Removes the given {@code runnable}from the UI threads queue if it is still queued.static voidassertMainThread()Throws an IllegalArgumentException if called on a thread other than the mainthread. static voidassertBackgroundThread()Throws an IllegalArgumentException if called on the main thread. static booleanisOnMainThread()Returns {@code true}if called on the main thread,{@code false}otherwise.static booleanisOnBackgroundThread()Returns {@code true}if called on a background thread,{@code false}otherwise.static <T> Queue<T>createQueue(int size)Creates a Queue of the given size using ImageModule preferred implementation. static <T> List<T>getSnapshot(@NonNull() Collection<T> other)Returns a copy of the given list that is safe to iterate over and perform actions that maymodify the original list. static booleanbothNullOrEqual(@Nullable() Object a, @Nullable() Object b)Null-safe equivalent of {@code a.equals(b)}.static booleanbothModelsNullEquivalentOrEquals(@Nullable() Object a, @Nullable() Object b)static inthashCode(int value)static inthashCode(int value, int accumulator)static inthashCode(float value)static inthashCode(float value, int accumulator)static inthashCode(@Nullable() Object object, int accumulator)static inthashCode(boolean value, int accumulator)static inthashCode(boolean value)-
-
Method Detail
-
sha256BytesToHex
@NonNull() static String sha256BytesToHex(@NonNull() Array<byte> bytes)
Returns the hex string of the given byte array representing a SHA256 hash.
-
getSize
@Deprecated() static int getSize(@NonNull() Bitmap bitmap)
Returns the allocated byte size of the given bitmap.
-
getBitmapByteSize
static int getBitmapByteSize(@NonNull() Bitmap bitmap)
Returns the in memory size of the given Bitmap in bytes.
-
getBitmapByteSize
static int getBitmapByteSize(int width, int height, @Nullable() Bitmap.Config config)
Returns the in memory size of Bitmap with the given width, height, and Bitmap.Config.
-
isValidDimensions
static boolean isValidDimensions(int width, int height)
Returns true if width and height are both > 0 and/or equal to SIZE_ORIGINAL.
-
postOnUiThread
static void postOnUiThread(Runnable runnable)
Posts the given
{@code runnable}to the UI thread using a shared Handler.
-
removeCallbacksOnUiThread
static void removeCallbacksOnUiThread(Runnable runnable)
Removes the given
{@code runnable}from the UI threads queue if it is still queued.
-
assertMainThread
static void assertMainThread()
Throws an IllegalArgumentException if called on a thread other than the mainthread.
-
assertBackgroundThread
static void assertBackgroundThread()
Throws an IllegalArgumentException if called on the main thread.
-
isOnMainThread
static boolean isOnMainThread()
Returns
{@code true}if called on the main thread,{@code false}otherwise.
-
isOnBackgroundThread
static boolean isOnBackgroundThread()
Returns
{@code true}if called on a background thread,{@code false}otherwise.
-
createQueue
@NonNull() static <T> Queue<T> createQueue(int size)
Creates a Queue of the given size using ImageModule preferred implementation.
-
getSnapshot
@NonNull() static <T> List<T> getSnapshot(@NonNull() Collection<T> other)
Returns a copy of the given list that is safe to iterate over and perform actions that maymodify the original list.
See #303, #375, #322, #2262.
-
bothNullOrEqual
static boolean bothNullOrEqual(@Nullable() Object a, @Nullable() Object b)
Null-safe equivalent of
{@code a.equals(b)}.
-
bothModelsNullEquivalentOrEquals
static boolean bothModelsNullEquivalentOrEquals(@Nullable() Object a, @Nullable() Object b)
-
hashCode
static int hashCode(int value)
-
hashCode
static int hashCode(int value, int accumulator)
-
hashCode
static int hashCode(float value)
-
hashCode
static int hashCode(float value, int accumulator)
-
hashCode
static int hashCode(boolean value, int accumulator)
-
hashCode
static int hashCode(boolean value)
-
-
-
-