public final class FlexibleUtils
extends java.lang.Object
DrawableUtils,
LayoutUtils| Modifier and Type | Field and Description |
|---|---|
static int |
colorAccent |
static java.lang.String |
DATE_TIME_FORMAT |
static int |
INVALID_COLOR |
static java.lang.String |
SPLIT_EXPRESSION |
| Constructor and Description |
|---|
FlexibleUtils() |
| Modifier and Type | Method and Description |
|---|---|
static int |
adjustAlpha(int color,
int alpha)
Adjusts the alpha of a color.
|
static int |
dpToPx(android.content.Context context,
float dp) |
static int |
fetchAccentColor(android.content.Context context,
int defColor)
Optimized method to fetch the accent color on devices with at least Lollipop.
|
static java.lang.String |
formatDateTime(java.util.Date date)
Predefined format:
dd MMM yyyy HH:mm:ss z |
static java.lang.String |
formatDateTime(java.util.Date date,
java.lang.String format)
Date formatter with the provided format.
|
static android.text.Spanned |
fromHtmlCompat(java.lang.String text) |
static java.lang.String |
getClassName(java.lang.Object o) |
static android.util.DisplayMetrics |
getDisplayMetrics(android.content.Context context) |
static java.lang.String |
getModeName(int mode) |
static android.graphics.Point |
getScreenDimensions(android.content.Context context) |
static int |
getVersionCode(android.content.Context context) |
static java.lang.String |
getVersionName(android.content.Context context) |
static boolean |
hasJellyBean()
API 16
|
static boolean |
hasLollipop()
API 21
|
static boolean |
hasMarshmallow()
API 23
|
static boolean |
hasNougat()
API 24
|
static boolean |
hasOreo()
API 26
|
static void |
hideSoftInput(android.app.Activity activity)
Show Soft Keyboard with new Thread.
|
static void |
hideSoftInputFrom(android.content.Context context,
android.view.View view)
Hide Soft Keyboard from Dialogs with new Thread.
|
static void |
highlightText(android.widget.TextView textView,
java.lang.String originalText,
java.lang.String constraint)
Sets a spannable text with the accent color into the provided TextView.
|
static void |
highlightText(android.widget.TextView textView,
java.lang.String originalText,
java.lang.String constraint,
int color)
Sets a spannable text with any highlight color into the provided TextView.
|
static void |
highlightWords(android.widget.TextView textView,
java.lang.String originalText,
java.lang.String constraints)
Sets a spannable text with the accent color for each word provided by the
constraint text into the provided TextView.
|
static void |
highlightWords(android.widget.TextView textView,
java.lang.String originalText,
java.lang.String constraints,
int color)
Sets a spannable text with any highlight color for each word provided by the
constraint text into the provided TextView.
|
static void |
resetAccentColor()
Reset the internal accent color to
INVALID_COLOR, to give the possibility
to re-fetch it at runtime, since once it is fetched it cannot be changed. |
static void |
reveal(android.view.View view,
int centerX,
int centerY)
Create the reveal effect animation.
|
static void |
showSoftInput(android.content.Context context,
android.view.View view)
Show Soft Keyboard with new Thread.
|
static void |
textAppearanceCompat(android.widget.TextView textView,
int resId) |
static java.lang.String |
toLowerCase(java.lang.String text) |
static void |
unReveal(android.view.View view,
int centerX,
int centerY)
Create the un-reveal effect animation.
|
public static final java.lang.String DATE_TIME_FORMAT
public static final java.lang.String SPLIT_EXPRESSION
public static final int INVALID_COLOR
public static int colorAccent
public static java.lang.String getVersionName(android.content.Context context)
public static int getVersionCode(android.content.Context context)
public static boolean hasOreo()
Build.VERSION_CODES.Opublic static boolean hasNougat()
Build.VERSION_CODES.Npublic static boolean hasMarshmallow()
Build.VERSION_CODES.Mpublic static boolean hasLollipop()
Build.VERSION_CODES.LOLLIPOPpublic static boolean hasJellyBean()
Build.VERSION_CODES.JELLY_BEANpublic static void highlightText(android.widget.TextView textView,
java.lang.String originalText,
java.lang.String constraint)
Multiple matches will be highlighted, but if the 2nd match is consecutive, the highlight is skipped.
Internally callsfetchAccentColor(Context, int).textView - the TextView to transform and which the originalText is assigned tooriginalText - the original text which the transformation is applied toconstraint - the text to highlighthighlightText(TextView, String, String, int),
highlightWords(TextView, String, String)public static void highlightText(android.widget.TextView textView,
java.lang.String originalText,
java.lang.String constraint,
int color)
Multiple matches will be highlighted, but if the 2nd match is consecutive, the highlight is skipped.
textView - the TextView to transform and which the originalText is assigned tooriginalText - the original text which the transformation is applied toconstraint - the text to highlightcolor - the highlight colorhighlightText(TextView, String, String),
highlightWords(TextView, String, String, int)public static void highlightWords(android.widget.TextView textView,
java.lang.String originalText,
java.lang.String constraints)
Note:
"([, ]+)" regular expression.fetchAccentColor(Context, int).textView - the TextView to transform and which the originalText is assigned tooriginalText - the original text which the transformation is applied toconstraints - the multiple words to highlighthighlightWords(TextView, String, String, int),
highlightText(TextView, String, String)public static void highlightWords(android.widget.TextView textView,
java.lang.String originalText,
java.lang.String constraints,
int color)
Note:
"([, ]+)" regular expression.textView - the TextView to transform and which the originalText is assigned tooriginalText - the original text which the transformation is applied toconstraints - the multiple words to highlightcolor - the highlight colorhighlightWords(TextView, String, String),
highlightText(TextView, String, String, int)public static java.lang.String toLowerCase(java.lang.String text)
public static android.text.Spanned fromHtmlCompat(java.lang.String text)
public static void textAppearanceCompat(android.widget.TextView textView,
int resId)
public static java.lang.String formatDateTime(java.util.Date date)
dd MMM yyyy HH:mm:ss zdate - the date to formatpublic static java.lang.String formatDateTime(java.util.Date date,
java.lang.String format)
date - the date to formatformat - the format to applypublic static java.lang.String getModeName(int mode)
SelectableAdapter.Modepublic static java.lang.String getClassName(java.lang.Object o)
SimpleClassName of the provided objectpublic static int adjustAlpha(int color,
int alpha)
color - the coloralpha - the alpha value we want to set 0-255public static void resetAccentColor()
INVALID_COLOR, to give the possibility
to re-fetch it at runtime, since once it is fetched it cannot be changed.public static int fetchAccentColor(android.content.Context context,
int defColor)
If accent color has been already fetched it is simply returned.
context - contextdefColor - value to return if the accentColor cannot be foundpublic static android.graphics.Point getScreenDimensions(android.content.Context context)
public static android.util.DisplayMetrics getDisplayMetrics(android.content.Context context)
public static int dpToPx(android.content.Context context,
float dp)
public static void showSoftInput(android.content.Context context,
android.view.View view)
public static void hideSoftInput(android.app.Activity activity)
public static void hideSoftInputFrom(android.content.Context context,
android.view.View view)
public static void reveal(android.view.View view,
int centerX,
int centerY)
view - the View to revealcenterX - the x coordinate of the center of the animating circle, relative to view.centerY - the y coordinate of the center of the animating circle, relative to view.public static void unReveal(android.view.View view,
int centerX,
int centerY)
View will be set as visibility GONE.
view - the View to revealcenterX - the x coordinate of the center of the animating circle, relative to view.centerY - the y coordinate of the center of the animating circle, relative to view.