public class Utilities extends Object
Modifier and Type | Field and Description |
---|---|
static Property<Drawable,Integer> |
DRAWABLE_ALPHA |
static Property<Drawable,Rect> |
DRAWABLE_RECT |
static Rect |
EMPTY_RECT |
static RectEvaluator |
RECT_EVALUATOR |
static RectFEvaluator |
RECTF_EVALUATOR |
Constructor and Description |
---|
Utilities() |
Modifier and Type | Method and Description |
---|---|
static void |
addTraceEvent(String event)
Adds a trace event for debugging.
|
static <T> ArraySet<T> |
arrayToSet(T[] array,
ArraySet<T> setOut)
Replaces the contents of with the contents of the .
|
static void |
cancelAnimationWithoutCallbacks(Animator animator)
Cancels an animation ensuring that if it has listeners, onCancel and onEnd
are not called.
|
static float |
clamp(float value,
float min,
float max) |
static int |
clamp(int value,
int min,
int max) |
static float |
clamp01(float value) |
static float |
computeContrastBetweenColors(int bg,
int fg)
Calculates the constrast between two colors, using the algorithm provided by the WCAG v2.
|
static float |
dpToPx(Resources res,
float dp)
Used for debugging, converts DP to PX.
|
static String |
dumpRect(Rect r)
Returns a lightweight dump of a rect.
|
static <T extends View> |
findParent(View v,
Class<T> parentClass) |
static ViewStub |
findViewStubById(Activity a,
int stubId)
Returns a view stub for the given view id.
|
static ViewStub |
findViewStubById(View v,
int stubId)
Returns a view stub for the given view id.
|
static Configuration |
getAppConfiguration(Context context)
Returns the application configuration, which is independent of the activity's current
configuration in multiwindow.
|
static int |
getColorWithOverlay(int baseColor,
int overlayColor,
float overlayAlpha)
Returns the base color overlaid with another overlay color with a specified alpha.
|
static boolean |
isDescendentAccessibilityFocused(View v)
Returns whether this view, or one of its descendants have accessibility focus.
|
static float |
mapRange(float value,
float min,
float max)
Scales the to be proportionally between the and
values.
|
static void |
matchTaskListSize(List<Task> tasks,
List<TaskViewTransform> transforms)
Updates to be the same size as .
|
static <T> ArraySet<T> |
objectToSet(T obj,
ArraySet<T> setOut)
Initializes the with the given object.
|
static void |
removeAnimationListenersRecursive(Animator animator)
Recursively removes all the listeners of all children of this animator
|
static void |
scaleRectAboutCenter(RectF r,
float scale)
Scales a rect about its centroid
|
static void |
setViewFrameFromTranslation(View v)
Sets the given
View 's frame from its current translation. |
static float |
unmapRange(float value,
float min,
float max)
Scales the proportionally from and to 0 and 1.
|
public static final RectFEvaluator RECTF_EVALUATOR
public static final RectEvaluator RECT_EVALUATOR
public static final Rect EMPTY_RECT
public static <T extends View> T findParent(View v, Class<T> parentClass)
parentClass
- must be a class derived from View
public static <T> ArraySet<T> objectToSet(T obj, ArraySet<T> setOut)
public static <T> ArraySet<T> arrayToSet(T[] array, ArraySet<T> setOut)
public static float clamp(float value, float min, float max)
public static int clamp(int value, int min, int max)
public static float clamp01(float value)
public static float mapRange(float value, float min, float max)
value
- must be between 0 and 1public static float unmapRange(float value, float min, float max)
value
- must be between and public static void scaleRectAboutCenter(RectF r, float scale)
public static float computeContrastBetweenColors(int bg, int fg)
public static int getColorWithOverlay(int baseColor, int overlayColor, float overlayAlpha)
public static void cancelAnimationWithoutCallbacks(Animator animator)
public static void removeAnimationListenersRecursive(Animator animator)
public static void setViewFrameFromTranslation(View v)
View
's frame from its current translation.public static ViewStub findViewStubById(View v, int stubId)
public static ViewStub findViewStubById(Activity a, int stubId)
public static void matchTaskListSize(List<Task> tasks, List<TaskViewTransform> transforms)
public static float dpToPx(Resources res, float dp)
public static void addTraceEvent(String event)
public static boolean isDescendentAccessibilityFocused(View v)
public static Configuration getAppConfiguration(Context context)