Class Dynamic
DynamicActivity and inflated views at runtime according
to their implemented types.
These methods are provided to avoid any exceptions when views are replaced by the
DynamicLayoutInflater or not using the DynamicActivity.
So, this is the recommended way to modify the activity or any of the following view types
at runtime.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceInterface to hold the vibration values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddBottomSheet(Context activity, int layoutRes, boolean removePrevious) Add view in the bottom sheet frame layout for theDynamicActivity.static voidaddBottomSheet(Context activity, View view, boolean removePrevious) Add view in the bottom sheet frame layout for theDynamicActivity.static voidAdd header view just below the app bar for theDynamicActivity.static voidAdd header view just below the app bar for theDynamicActivity.static voidAdd header view just below the app bar for theDynamicActivity.static voidAdd header view just below the app bar for theDynamicActivity.static voidaddSearchViewTextChangedListener(Context activity, TextWatcher textWatcher) Adds the text watcher to listen search view text changes for theDynamicActivity.static voidcollapseSearchView(Context activity) Collapse search view to stop searching for theDynamicActivity.static voidexpandSearchView(Context activity, boolean requestSoftInput) Expand search view to start searching for theDynamicActivity.static ViewfindViewById(View view, int viewId) Try to find view for the supplied view id.static IcongetAppShortcutIcon(Context context, int drawableRes, int backgroundId, int foregroundId, boolean theme) Returns the app shortcut icon according to the dynamic theme.static <T,V> int CallTutorial.getColor()method for theTutorial.static <T> intgetColor(T dynamic, int defaultColor) Returns the color for the supplied dynamic object.static intgetContrast(int contrast) Returns the resolved contrast for the supplied value.static <T> intgetContrast(T dynamic) Returns the contrast for the supplied dynamic object.static <T> intgetContrastWithColor(T dynamic, int defaultColor) Returns the contrast with color for the supplied dynamic object.static floatgetElevation(View view, float defaultElevation) Returns the elevation for the supplied view.static intgetTintColor(int color) Returns the tint color according to the applied theme.static intgetTintColor(int color, float visibleContrast) Returns the tint color according to the supplied visible contrast.static <T extends BackgroundAware<?>>
intgetTintColor(int color, T theme) Returns the tint color according to the supplied theme.static <T,V> int getTintColor(Tutorial<T, V> tutorial, int defaultColor) CallTutorial.getTintColor()method for theTutorial.static booleanisBackgroundAware(int backgroundAware) Checks whether the background aware functionality is enabled for the supplied value.static <T> booleanisBackgroundAware(T dynamic) Checks whether the background aware functionality is enabled for the supplied dynamic object.static <T extends DynamicColor<T>>
booleanisDynamicColor(T theme) Checks whether the dynamic theme object has dynamic colors enabled.static booleanChecks whether the theme styles version is legacy.static booleanisLegacyVersion(int version) Checks whether the supplied theme styles version is legacy.static booleanisLegacyVersion(String version) Checks whether the supplied theme styles version is legacy.static booleanChecks whether the application theme styles version is legacy.static booleanisSearchViewExpanded(Context activity) Checks whether the search view is expanded for theDynamicActivity.static booleanisStroke()Checks whether the stroke is required for the current theme.static <T extends StrokeTheme<?>>
booleanisStroke(T theme) Checks whether the stroke is required for the supplied theme.static StringLoad the theme styles version from the shared preferences.static StringloadThemeVersion(boolean resolve) Load the theme styles version from the shared preferences.static <T,V> void onColorChanged(Tutorial<T, V> tutorial, int color, int tint) CallTutorial.onColorChanged(int, int)method for theTutorial.static voidonPageScrolled(ViewPager.OnPageChangeListener pager, int position, float positionOffset, int positionOffsetPixels) CallViewPager.OnPageChangeListener.onPageScrolled(int, float, int)method for theViewPager.static voidonPageScrollStateChanged(ViewPager.OnPageChangeListener pager, int state) CallView.onScreenStateChanged(int)method for theViewPager.static voidonPageSelected(ViewPager.OnPageChangeListener pager, int position) CallViewPager.OnPageChangeListener.onPageSelected(int)method for theViewPager.static <T,V> void onSetPadding(Tutorial<T, V> tutorial, int left, int top, int right, int bottom) CallTutorial.onSetPadding(int, int, int, int)method for theTutorial.static voidremoveSearchViewTextChangedListener(Context activity, TextWatcher textWatcher) Removes the text watcher from the search view to stop listening text changes for theDynamicActivity.static intresolveColor(int background, int color, int tint, boolean backgroundAware) Resolves a color based on the supplied parameters.static intresolveTintColor(int background, int color, int tint, boolean backgroundAware) Resolves a color based on the supplied parameters.static voidrestoreSearchViewState(Context activity) Restore the search view state after the configuration change for theDynamicActivity.static voidsaveThemeVersion(String version) Save the theme styles version into the shared preferences.static voidSet bitmap for the image view and manage its visibility according to the data.static voidSet drawable for the image view and manage its visibility according to the data.static voidSet rating value for the rating bar.static voidset(TextView textView, CharSequence text) Set text for the text view and manage its visibility according to the data.static voidSet text for the text view and manage its visibility according to the data.static voidsetAllCapsIfRequired(TextView textView, boolean allCaps) Set the text view all caps according to the theme styles version.static voidSet alpha for the view.static voidsetAppBarProgressVisible(Context activity, boolean visible) Set the visibility of app bar progress for theDynamicActivity.static voidsetBackground(View view, int drawableRes) Set background drawable resource for the view.static voidsetBackground(View view, Drawable drawable) Set background drawable for the view.static <T> voidsetBackgroundAware(T dynamic, int backgroundAware) Sets the background aware for the supplied dynamic object.static <T> voidsetBackgroundAware(T dynamic, int backgroundAware, int contrast) Sets the background aware and contrast for the supplied dynamic object.static <V,T extends BackgroundAware<?>>
voidsetBackgroundAware(V dynamic, T theme) Sets the background aware and contrast for the dynamic object according to the supplied theme.static <T> voidsetBackgroundAwareSafe(T dynamic, int backgroundAware) Sets the background aware for the supplied dynamic object after doing appropriate checks.static <T> voidsetBackgroundAwareSafe(T dynamic, int backgroundAware, int contrast) Sets the background aware and contrast for the supplied dynamic object after doing appropriate checks.static <T> voidsetBackgroundColor(T dynamic, int color) Sets the background color for the supplied dynamic object.static <T> voidsetBackgroundColorType(T dynamic, int colorType) Sets the background color type for the supplied dynamic object.static voidsetBottomSheetState(Context activity, int bottomSheetState) Sets the bottom sheet state if present for theDynamicActivity.static <T> voidsetClickable(T dynamic, boolean clickable) Set the clickable property for the dynamic object.static voidsetClickListener(View view, View.OnClickListener clickListener) Set click listener for the view and manage its visibility according to the data.static voidsetClickListener(View view, View.OnClickListener clickListener, boolean visibility) Set click listener for the view and manage its visibility according to the data.static <T> voidsetColor(T dynamic) Refresh the color for the supplied dynamic object.static <T> voidsetColor(T dynamic, int color) Sets the color for the supplied dynamic object.static <T> voidsetColorType(T dynamic, int colorType) Sets the color type for the supplied dynamic object.static <T> voidsetColorTypeOrColor(T dynamic, int colorType, int color) Sets the color type or color for the supplied dynamic object after doing the appropriate checks.static voidsetContentDescription(ImageView imageView, String text) Set content description for the image view.static <T> voidsetContrastWithColor(T dynamic, int color) Sets the contrast with color for the supplied dynamic object.static <T> voidsetContrastWithColorType(T dynamic, int colorType) Sets the contrast with color type for the supplied dynamic object.static <T> voidsetContrastWithColorTypeOrColor(T dynamic, int colorType, int color) Sets the contrast with color type or color for the supplied dynamic object after doing the appropriate checks.static voidSets the corner for the supplied view.static voidsetCornerMin(View view, float cornerMax) Sets the minimum corner value for the supplied view.static voidsetElevation(View view, float elevation) Sets elevation for the supplied view.static voidsetEnabled(View view, boolean enabled) Set a view enabled or disabled.static voidsetForceElevation(View view, boolean forceElevation) Sets whether to force elevation for the supplied view.static voidsetHtml(TextView textView, CharSequence text) SetHTMLtext for the text view and manage its visibility according to the data.static <T> voidsetLinkColor(T dynamic) Refresh the link color for the supplied dynamic object.static <T> voidsetLinkColor(T dynamic, int color) Sets the link color for the supplied dynamic object.static <T> voidsetLinkColorType(T dynamic, int colorType) Sets the link color type for the supplied dynamic object.static <T> voidsetLongClickable(T dynamic, boolean longClickable) Set the long clickable property for the dynamic object.static <T> voidsetOnClickListener(T dynamic, View.OnClickListener onClickListener) Set on click listener for the dynamic object.static <T> voidsetOnLongClickListener(T dynamic, View.OnLongClickListener onLongClickListener) Set on long click listener for the dynamic object.static voidsetPreventCornerOverlap(View view, boolean preventCornerOverlap) Sets the prevent corner overlap for the supplied view.static voidsetResource(View view, int drawableRes) Set drawable for the image view and manage its visibility according to the data.static <T> voidsetRootBackground(T dynamic, int color) Sets the background for the window or root view.static <T> voidsetScrollBarColor(T dynamic) Refresh the scroll bar color for the supplied dynamic object.static <T> voidsetScrollBarColor(T dynamic, int color) Sets the scroll bar color for the supplied dynamic object.static <T> voidsetScrollBarColorType(T dynamic, int colorType) Sets the scroll bar color type for the supplied dynamic object.static voidsetSearchViewListener(Context activity, DynamicSearchListener searchListener) Sets the listener to listen the search view expand and collapse callbacks for theDynamicActivity.static <T> voidsetStateNormalColor(T dynamic, int color) Sets the normal state color for the supplied dynamic object.static <T> voidsetStateNormalColorType(T dynamic, int colorType) Sets the normal state color type for the supplied dynamic object.static <T> voidsetStateSelectedColor(T dynamic, int color) Sets the selected state color for the supplied dynamic object.static <T> voidsetStateSelectedColorType(T dynamic, int colorType) Sets the selected state color type for the supplied dynamic object.static <T> voidsetStrokeColor(T dynamic, int color) Sets the stroke color for the supplied dynamic object.static voidSet text for the text view and manage its visibility according to the data.static <T> voidsetTextColor(T dynamic) Refresh the text color for the supplied dynamic object.static <T> voidsetTextColor(T dynamic, int color) Sets the text color for the supplied dynamic object.static <T> voidsetTextColorType(T dynamic, int colorType) Sets the text color type for the supplied dynamic object.static <T extends TypeTheme<?>>
TsetThemeType(T theme, int type) Sets the type for the supplied dynamic theme object.static <T extends TypeTheme<?>>
TsetThemeType(T theme, T parent) Sets the type for the supplied dynamic theme object.static voidsetTooltip(View view) Set tooltip for the supplied view.static voidsetTooltip(View view, int backgroundColor, int tintColor) Set tooltip for the supplied view.static voidsetTooltip(View view, int backgroundColor, int tintColor, CharSequence text) Set tooltip for the supplied view.static voidsetTooltip(View view, CharSequence text) Set tooltip for the supplied view.static voidsetTransitionName(View view, String name) Sets the transition name for the supplied view.static voidsetTransitionPosition(Context activity, int transitionPosition) Sets the transition position for theDynamicActivity.static voidsetTransitionResultCode(Context activity, int transitionResultCode) Sets the transition result code for theDynamicActivity.static voidsetVisibility(View view, int visibility) Set visibility for the view.static voidsetVisibility(View view, View base) Set visibility for the view according to the base view.static voidshowSnackbar(Context activity, int stringRes) Show the snackbar for theDynamicSnackbar.static voidshowSnackbar(Context activity, int stringRes, int duration) Show the snackbar for theDynamicSnackbar.static voidshowSnackbar(Context activity, CharSequence text) Show the snackbar for theDynamicSnackbar.static voidshowSnackbar(Context activity, CharSequence text, int duration) Show the snackbar for theDynamicSnackbar.static voidstartMotionActivityFromFragment(Context activity, Fragment fragment, Intent intent, int requestCode, Bundle options) Called by Fragment.startActivityForResult() to implement its behavior for theDynamicActivity.static voidstartMotionActivityFromFragment(Context activity, Fragment fragment, Intent intent, int requestCode, Bundle options, boolean finish, boolean afterTransition) Called by Fragment.startActivityForResult() to implement its behavior for theDynamicActivity.static <T> voidtint(T dynamic, int color) Tint dynamic object according to the supplied colors.static <T> voidtint(T dynamic, int color, int contrastWithColor) Tint dynamic object according to the supplied colors.static <T> voidtintBackground(T dynamic) Tint background according to the default contrast with color.static <T> voidtintBackground(T dynamic, int contrastWithColor) Tint background according to the supplied contrast with color.static <T> voidtintBackground(T dynamic, int contrastWithColor, boolean borderless) Tint background according to the supplied contrast with color.static <T> voidtintBackground(T dynamic, int contrastWithColor, int color, boolean borderless) Tint background according to the supplied colors.static <T> voidtintForeground(T dynamic, int contrastWithColor) Tint foreground according to the supplied contrast with color.static <T> voidtintForeground(T dynamic, int contrastWithColor, boolean borderless) Tint foreground according to the supplied contrast with color.static <T> voidtintForeground(T dynamic, int contrastWithColor, int color, boolean borderless) Tint foreground according to the supplied colors.static <T> voidtintScrollable(T dynamic) Tint scrollable according to the default contrast with color.static <T> voidtintScrollable(T dynamic, int contrastWithColor) Tint scrollable according to the supplied contrast with color.static intwithContrastRatio(int color, int contrastWith) Returns the contrast color according to the applied theme.static intwithContrastRatio(int color, int contrastWith, float visibleContrast) Returns the contrast color according to the supplied visible contrast.static <T extends BackgroundAware<?>>
intwithContrastRatio(int color, int contrastWith, T theme) Returns the contrast color according to the supplied theme.static intwithThemeOpacity(int color) Sets the translucent theme opacity for the supplied color.static intwithThemeOpacity(int color, int min) Sets the translucent theme opacity for the supplied color.static <T extends TranslucentTheme<?>>
intwithThemeOpacity(int color, T theme) Sets the translucent theme opacity for the supplied color.static <T extends TranslucentTheme<?>>
intwithThemeOpacity(int color, T theme, int min) Sets the translucent theme opacity for the supplied color.static DrawablewithThemeOpacity(Drawable drawable) Sets the translucent theme opacity for the supplied drawable.static DrawablewithThemeOpacity(Drawable drawable, int min) Sets the translucent theme opacity for the supplied drawable.static <T extends TranslucentTheme<?>>
DrawablewithThemeOpacity(Drawable drawable, T theme) Sets the translucent theme opacity for the supplied drawable.static <T extends TranslucentTheme<?>>
DrawablewithThemeOpacity(Drawable drawable, T theme, int min) Sets the translucent theme opacity for the supplied drawable.
-
Constructor Details
-
Dynamic
public Dynamic()
-
-
Method Details
-
loadThemeVersion
Load the theme styles version from the shared preferences.- Parameters:
resolve-trueto resolve the auto theme version.- Returns:
- The theme styles version from the shared preferences.
-
loadThemeVersion
Load the theme styles version from the shared preferences.- Returns:
- The theme styles version from the shared preferences.
- See Also:
-
saveThemeVersion
Save the theme styles version into the shared preferences.- Parameters:
version- The version to be saved.
-
isLegacyVersion
public static boolean isLegacyVersion(int version) Checks whether the supplied theme styles version is legacy.- Parameters:
version- The version to be checked.- Returns:
trueif the supplied theme styles version is legacy.
-
isLegacyVersion
Checks whether the supplied theme styles version is legacy.- Parameters:
version- The version to be checked.- Returns:
trueif the supplied theme styles version is legacy.
-
isLegacyVersion
public static boolean isLegacyVersion()Checks whether the theme styles version is legacy.- Returns:
trueif the theme styles version is legacy.- See Also:
-
isLegacyVersionRemote
public static boolean isLegacyVersionRemote()Checks whether the application theme styles version is legacy.- Returns:
trueif the application theme styles version is legacy.- See Also:
-
setAllCapsIfRequired
Set the text view all caps according to the theme styles version.- Parameters:
textView- The text view to be used.allCaps-trueto set the all caps.- See Also:
-
resolveColor
@ColorInt public static int resolveColor(@ColorInt int background, @ColorInt int color, @ColorInt int tint, boolean backgroundAware) Resolves a color based on the supplied parameters.- Parameters:
background- The background color to be considered.color- The color to be resolved.tint- The tint color to be resolved.backgroundAware-trueif the background aware is enabled.- Returns:
- The resolved color based on the supplied parameters.
-
resolveTintColor
@ColorInt public static int resolveTintColor(@ColorInt int background, @ColorInt int color, @ColorInt int tint, boolean backgroundAware) Resolves a color based on the supplied parameters.- Parameters:
background- The background color to be considered.color- The color to be resolved.tint- The tint color to be resolved.backgroundAware-trueif the background aware is enabled.- Returns:
- The resolved color based on the supplied parameters.
-
setColorType
Sets the color type for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.- See Also:
-
setBackgroundColorType
Sets the background color type for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.- See Also:
-
setContrastWithColorType
Sets the contrast with color type for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.- See Also:
-
setTextColorType
Sets the text color type for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.- See Also:
-
setLinkColorType
Sets the link color type for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.- See Also:
-
setStateNormalColorType
Sets the normal state color type for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.- See Also:
-
setStateSelectedColorType
Sets the selected state color type for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.- See Also:
-
setScrollBarColorType
Sets the scroll bar color type for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.- See Also:
-
getColor
Returns the color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.defaultColor- The default color to be used.- Returns:
- The color for the supplied dynamic object.
- See Also:
-
setColor
Sets the color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The color to be set.- See Also:
-
setColor
Refresh the color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.- See Also:
-
setBackgroundColor
Sets the background color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The color to be set.- See Also:
-
setStrokeColor
Sets the stroke color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The stroke color to be set.
-
getContrastWithColor
@ColorInt public static <T> int getContrastWithColor(@Nullable T dynamic, @ColorInt int defaultColor) Returns the contrast with color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.defaultColor- The default color to be used.- Returns:
- The contrast color for the supplied dynamic object.
- See Also:
-
setContrastWithColor
Sets the contrast with color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The color to be set.- See Also:
-
setTextColor
Sets the text color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The color to be set.- See Also:
-
setTextColor
Refresh the text color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.- See Also:
-
setLinkColor
Sets the link color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The color to be set.- See Also:
-
setLinkColor
Refresh the link color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.- See Also:
-
setStateNormalColor
Sets the normal state color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The color to be set.- See Also:
-
setStateSelectedColor
Sets the selected state color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The color to be set.- See Also:
-
setScrollBarColor
Sets the scroll bar color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The color to be set.- See Also:
-
setScrollBarColor
Refresh the scroll bar color for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.- See Also:
-
isStroke
Checks whether the stroke is required for the supplied theme.- Type Parameters:
T- The type of the dynamic theme.- Parameters:
theme- The theme object to be used.- Returns:
trueif the stroke is required for the supplied theme.
-
isStroke
public static boolean isStroke()Checks whether the stroke is required for the current theme.- Returns:
trueif the stroke is required for the current theme.
-
isBackgroundAware
public static boolean isBackgroundAware(int backgroundAware) Checks whether the background aware functionality is enabled for the supplied value.- Parameters:
backgroundAware- The value to be checked.- Returns:
trueif the supplied value changes color according to the background.- See Also:
-
isBackgroundAware
Checks whether the background aware functionality is enabled for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be checked.- Returns:
trueif the supplied dynamic object changes color according to the background.- See Also:
-
setBackgroundAware
Sets the background aware and contrast for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.backgroundAware- The background aware option to be set.contrast- The contrast to be set.- See Also:
-
setBackgroundAware
public static <V,T extends BackgroundAware<?>> void setBackgroundAware(@Nullable V dynamic, @Nullable T theme) Sets the background aware and contrast for the dynamic object according to the supplied theme.- Type Parameters:
V- The type of the dynamic object.T- The type of the dynamic theme.- Parameters:
dynamic- The dynamic object to be used.theme- The theme object to be used.- See Also:
-
setBackgroundAware
Sets the background aware for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.backgroundAware- The background aware option to be set- See Also:
-
getContrast
public static int getContrast(int contrast) Returns the resolved contrast for the supplied value.- Parameters:
contrast- The contrast to be resolved.- Returns:
- The resolved contrast for the supplied value.
- See Also:
-
getContrast
Returns the contrast for the supplied dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.- Returns:
- The contrast for the supplied dynamic object.
- See Also:
-
withContrastRatio
@ColorInt public static int withContrastRatio(@ColorInt int color, @ColorInt int contrastWith, float visibleContrast) Returns the contrast color according to the supplied visible contrast.- Parameters:
color- The color to be used.contrastWith- The contrast with color to be used.visibleContrast- The minimum ratio for the visible contrast.- Returns:
- The contrast color according to the supplied visible contrast.
- See Also:
-
withContrastRatio
@ColorInt public static <T extends BackgroundAware<?>> int withContrastRatio(@ColorInt int color, @ColorInt int contrastWith, @Nullable T theme) Returns the contrast color according to the supplied theme.- Type Parameters:
T- The type of the theme.- Parameters:
color- The color to be used.contrastWith- The contrast with color to be used.theme- The theme object to be used.- Returns:
- The contrast color according to the supplied theme.
- See Also:
-
withContrastRatio
Returns the contrast color according to the applied theme.- Parameters:
color- The color to be used.contrastWith- The contrast with color to be used.- Returns:
- The contrast color according to the applied theme.
- See Also:
-
withContrastRatio
@ColorInt public static <T> int withContrastRatio(@ColorInt int color, @ColorInt int contrastWith, @Nullable T view) Returns the contrast color according to the supplied dynamic widget.- Type Parameters:
T- The type of the dynamic widget.- Parameters:
color- The color to be used.contrastWith- The contrast with color to be used.view- The view object to be used.- Returns:
- The contrast color according to the supplied dynamic widget.
- See Also:
-
getTintColor
Returns the tint color according to the supplied visible contrast.- Parameters:
color- The color to be used.visibleContrast- The minimum ratio for the visible contrast.- Returns:
- The tint color according to the supplied visible contrast.
- See Also:
-
getTintColor
@ColorInt public static <T extends BackgroundAware<?>> int getTintColor(@ColorInt int color, @Nullable T theme) Returns the tint color according to the supplied theme.- Type Parameters:
T- The type of the theme.- Parameters:
color- The color to be used.theme- The theme object to be used.- Returns:
- The tint color according to the supplied theme.
- See Also:
-
getTintColor
Returns the tint color according to the applied theme.- Parameters:
color- The color to be used.- Returns:
- The tint color according to the applied theme.
- See Also:
-
getTintColor
Returns the tint color according to the supplied dynamic widget.- Type Parameters:
T- The type of the dynamic widget.- Parameters:
color- The color to be used.view- The view object to be used.- Returns:
- The tint color according to the supplied dynamic widget.
- See Also:
-
withThemeOpacity
@ColorInt public static <T extends TranslucentTheme<?>> int withThemeOpacity(@ColorInt int color, @Nullable T theme, @IntRange(from=0L,to=255L) int min) Sets the translucent theme opacity for the supplied color.- Type Parameters:
T- The type of the dynamic theme.- Parameters:
color- The color to be used.theme- The theme object to be used.min- The minimum opacity to be used.- Returns:
- The color after applying the theme opacity.
- See Also:
-
withThemeOpacity
@ColorInt public static <T extends TranslucentTheme<?>> int withThemeOpacity(@ColorInt int color, @Nullable T theme) Sets the translucent theme opacity for the supplied color.- Type Parameters:
T- The type of the dynamic theme.- Parameters:
color- The color to be used.theme- The theme object to be used.- Returns:
- The color after applying the theme opacity.
- See Also:
-
withThemeOpacity
@ColorInt public static int withThemeOpacity(@ColorInt int color, @IntRange(from=0L,to=255L) int min) Sets the translucent theme opacity for the supplied color.- Parameters:
color- The color to be used.min- The minimum opacity to be used.- Returns:
- The color after applying the theme opacity.
- See Also:
-
withThemeOpacity
Sets the translucent theme opacity for the supplied color.- Parameters:
color- The color to be used.- Returns:
- The color after applying the theme opacity.
- See Also:
-
withThemeOpacity
@Nullable public static <T extends TranslucentTheme<?>> Drawable withThemeOpacity(@Nullable Drawable drawable, @Nullable T theme, @IntRange(from=0L,to=255L) int min) Sets the translucent theme opacity for the supplied drawable.- Type Parameters:
T- The type of the dynamic theme.- Parameters:
drawable- The drawable to be used.theme- The theme object to be used.min- The minimum opacity to be used.- Returns:
- The drawable after applying the theme opacity.
- See Also:
-
withThemeOpacity
@Nullable public static <T extends TranslucentTheme<?>> Drawable withThemeOpacity(@Nullable Drawable drawable, @Nullable T theme) Sets the translucent theme opacity for the supplied drawable.- Type Parameters:
T- The type of the dynamic theme.- Parameters:
drawable- The drawable to be used.theme- The theme object to be used.- Returns:
- The drawable after applying the theme opacity.
- See Also:
-
withThemeOpacity
@Nullable public static Drawable withThemeOpacity(@Nullable Drawable drawable, @IntRange(from=0L,to=255L) int min) Sets the translucent theme opacity for the supplied drawable.- Parameters:
drawable- The drawable to be used.min- The minimum opacity to be used.- Returns:
- The drawable after applying the theme opacity.
- See Also:
-
withThemeOpacity
Sets the translucent theme opacity for the supplied drawable.- Parameters:
drawable- The drawable to be used.- Returns:
- The drawable after applying the theme opacity.
- See Also:
-
setThemeType
Sets the type for the supplied dynamic theme object.- Type Parameters:
T- The type of the theme object.- Parameters:
theme- The theme object to be used.type- The theme type to be set.- Returns:
- The theme object after setting the type.
- See Also:
-
setThemeType
Sets the type for the supplied dynamic theme object.- Type Parameters:
T- The type of the theme object.- Parameters:
theme- The theme object to be used.parent- The parent theme to be used.- Returns:
- The theme object after setting the type.
- See Also:
-
setColorTypeOrColor
Sets the color type or color for the supplied dynamic object after doing the appropriate checks.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.color- The color to be set.- See Also:
-
setContrastWithColorTypeOrColor
public static <T> void setContrastWithColorTypeOrColor(@Nullable T dynamic, int colorType, @ColorInt int color) Sets the contrast with color type or color for the supplied dynamic object after doing the appropriate checks.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.colorType- The color type to be set.color- The color to be set.- See Also:
-
setBackgroundAwareSafe
public static <T> void setBackgroundAwareSafe(@Nullable T dynamic, int backgroundAware, int contrast) Sets the background aware and contrast for the supplied dynamic object after doing appropriate checks.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.backgroundAware- The background aware option to be set.contrast- The contrast to be set.- See Also:
-
setBackgroundAwareSafe
Sets the background aware for the supplied dynamic object after doing appropriate checks.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.backgroundAware- The background aware option to be set.- See Also:
-
isDynamicColor
Checks whether the dynamic theme object has dynamic colors enabled.- Type Parameters:
T- The type of the theme object.- Parameters:
theme- The theme object to be used.- Returns:
trueif the dynamic theme object has dynamic colors enabled.- See Also:
-
tint
public static <T> void tint(@Nullable T dynamic, @ColorInt int color, @ColorInt int contrastWithColor) Tint dynamic object according to the supplied colors.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.color- The color to be set.contrastWithColor- The contrast with color to be set.- See Also:
-
tint
Tint dynamic object according to the supplied colors.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.color- The color to be set.- See Also:
-
tintBackground
public static <T> void tintBackground(@Nullable T dynamic, @ColorInt int contrastWithColor, @ColorInt int color, boolean borderless) Tint background according to the supplied colors.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.contrastWithColor- The contrast with color to be considered.color- The tint color to be applied.borderless-trueif the view is borderless.- See Also:
-
tintBackground
public static <T> void tintBackground(@Nullable T dynamic, @ColorInt int contrastWithColor, boolean borderless) Tint background according to the supplied contrast with color.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.contrastWithColor- The contrast with color to be considered.borderless-trueif the view is borderless.- See Also:
-
tintBackground
Tint background according to the supplied contrast with color.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.contrastWithColor- The contrast with color to be considered.- See Also:
-
tintBackground
Tint background according to the default contrast with color.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.- See Also:
-
tintForeground
public static <T> void tintForeground(@Nullable T dynamic, @ColorInt int contrastWithColor, @ColorInt int color, boolean borderless) Tint foreground according to the supplied colors.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.contrastWithColor- The contrast with color to be considered.color- The tint color to be applied.borderless-trueif the view is borderless.- See Also:
-
tintForeground
public static <T> void tintForeground(@Nullable T dynamic, @ColorInt int contrastWithColor, boolean borderless) Tint foreground according to the supplied contrast with color.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.contrastWithColor- The contrast with color to be considered.borderless-trueif the view is borderless.- See Also:
-
tintForeground
Tint foreground according to the supplied contrast with color.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.contrastWithColor- The contrast with color to be considered.- See Also:
-
tintScrollable
Tint scrollable according to the supplied contrast with color.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.contrastWithColor- The contrast with color to be considered.- See Also:
-
tintScrollable
Tint scrollable according to the default contrast with color.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be tinted.- See Also:
-
setOnClickListener
public static <T> void setOnClickListener(@Nullable T dynamic, @Nullable View.OnClickListener onClickListener) Set on click listener for the dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.onClickListener- The click listener to be set.- See Also:
-
setOnLongClickListener
public static <T> void setOnLongClickListener(@Nullable T dynamic, @Nullable View.OnLongClickListener onLongClickListener) Set on long click listener for the dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.onLongClickListener- The long click listener to be set.- See Also:
-
setClickable
Set the clickable property for the dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.clickable-trueto make it clickable.- See Also:
-
setLongClickable
Set the long clickable property for the dynamic object.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.longClickable-trueto make it long clickable.- See Also:
-
setPreventCornerOverlap
Sets the prevent corner overlap for the supplied view.- Parameters:
view- The view to be used.preventCornerOverlap- The value to be set.- See Also:
-
setCorner
Sets the corner for the supplied view.- Parameters:
view- The view to be used.corner- The corner to be set.- See Also:
-
DynamicButton.setCorner(Integer)DynamicNavigationView.setCorner(Float)DynamicBottomNavigationView.setCorner(Float)DynamicNavigationRailView.setCorner(Float)DynamicFloatingActionButton.setCorner(Float)DynamicCardView.setCorner(Float)DynamicMaterialCardView.setCorner(Float)DynamicTextInputLayout.setCorner(Float)DynamicColorView.setCornerRadius(float)
-
setCornerMin
Sets the minimum corner value for the supplied view.- Parameters:
view- The view to be used.cornerMax- The maximum corner value.- See Also:
-
setForceElevation
Sets whether to force elevation for the supplied view.- Parameters:
view- The view to be used.forceElevation-trueto force elevation.
-
getElevation
Returns the elevation for the supplied view.- Parameters:
view- The view to be used.defaultElevation- The default elevation to be used.- Returns:
- The elevation for the supplied view.
-
setElevation
Sets elevation for the supplied view.- Parameters:
view- The view to be used.elevation- The elevation to be set.
-
setRootBackground
Sets the background for the window or root view.- Type Parameters:
T- The type of the dynamic object.- Parameters:
dynamic- The dynamic object to be used.color- The color to be set.- See Also:
-
setBackground
Set background drawable for the view.- Parameters:
view- The view to set the background.drawable- The drawable to be set.- See Also:
-
setBackground
Set background drawable resource for the view.- Parameters:
view- The view to set the background.drawableRes- The drawable resource to be set.- See Also:
-
set
Set drawable for the image view and manage its visibility according to the data.- Parameters:
imageView- The image view to set the drawable.drawable- The drawable to be set.
-
set
Set bitmap for the image view and manage its visibility according to the data.- Parameters:
imageView- The image view to set the drawable.bitmap- The bitmap to be set.
-
setContentDescription
Set content description for the image view.- Parameters:
imageView- The image view to set the content description.text- The content description to be set.
-
set
Set text for the text view and manage its visibility according to the data.- Parameters:
textView- The text view to set the text.text- The text to be set.
-
set
Set text for the text view and manage its visibility according to the data.- Parameters:
textView- The text view to set the text.text- The text to be set.
-
set
Set rating value for the rating bar.- Parameters:
ratingBar- The rating bar to set the rating.rating- The rating value to be set.
-
setHtml
SetHTMLtext for the text view and manage its visibility according to the data.- Parameters:
textView- The text view to set the text.text- The text to be set.
-
setResource
Set drawable for the image view and manage its visibility according to the data.- Parameters:
view- The view to set the drawable.drawableRes- The drawable resource id to be set.
-
setText
Set text for the text view and manage its visibility according to the data.- Parameters:
textView- The text view to set the text.stringRes- The string resource id to be set.
-
setTooltip
public static void setTooltip(@Nullable View view, @ColorInt int backgroundColor, @ColorInt int tintColor, @Nullable CharSequence text) Set tooltip for the supplied view.- Parameters:
view- The view to be used.backgroundColor- The background color to be set.tintColor- The tint color to be set.text- The tooltip text to be set.- See Also:
-
setTooltip
public static void setTooltip(@Nullable View view, @ColorInt int backgroundColor, @ColorInt int tintColor) Set tooltip for the supplied view.- Parameters:
view- The view to be used.backgroundColor- The background color to be set.tintColor- The tint color to be set.- See Also:
-
setTooltip
Set tooltip for the supplied view.- Parameters:
view- The view to be used.text- The tooltip text to be set.- See Also:
-
setTooltip
Set tooltip for the supplied view.- Parameters:
view- The view to be used.- See Also:
-
setClickListener
public static void setClickListener(@Nullable View view, @Nullable View.OnClickListener clickListener, boolean visibility) Set click listener for the view and manage its visibility according to the data.- Parameters:
view- The view to set the click listener.clickListener- The click listener to be set.visibility-trueto manage the visibility.
-
setClickListener
public static void setClickListener(@Nullable View view, @Nullable View.OnClickListener clickListener) Set click listener for the view and manage its visibility according to the data.- Parameters:
view- The view to set the click listener.clickListener- The click listener to be set.
-
setVisibility
Set visibility for the view.- Parameters:
view- The view to set the visibility.visibility- The visibility to be set.
-
setVisibility
Set visibility for the view according to the base view.- Parameters:
view- The view to set the visibility.base- The view to get the visibility.
-
setEnabled
Set a view enabled or disabled.- Parameters:
view- The view to be enabled or disabled.enabled-trueto enable the view.
-
setAlpha
Set alpha for the view.- Parameters:
view- The view to set the alpha.alpha- The alpha to be set.
-
setAppBarProgressVisible
Set the visibility of app bar progress for theDynamicActivity.- Parameters:
activity- The activity to be used.visible-trueto show the progress bar below the app bar.
-
showSnackbar
public static void showSnackbar(@Nullable Context activity, @Nullable CharSequence text, int duration) Show the snackbar for theDynamicSnackbar.- Parameters:
activity- The activity context to be used.text- The text for the snackbar.duration- The duration of the snackbar.BaseTransientBottomBar.LENGTH_SHORT,BaseTransientBottomBar.LENGTH_LONGorBaseTransientBottomBar.LENGTH_INDEFINITE.
-
showSnackbar
Show the snackbar for theDynamicSnackbar.- Parameters:
activity- The activity context to be used.text- The text for the snackbar.D
-
showSnackbar
Show the snackbar for theDynamicSnackbar.- Parameters:
activity- The activity context to be used.stringRes- The string resource for the snackbar.duration- The duration of the snackbar.BaseTransientBottomBar.LENGTH_SHORT,BaseTransientBottomBar.LENGTH_LONGorBaseTransientBottomBar.LENGTH_INDEFINITE.
-
showSnackbar
Show the snackbar for theDynamicSnackbar.- Parameters:
activity- The activity context to be used.stringRes- The string resource for the snackbar.
-
setBottomSheetState
Sets the bottom sheet state if present for theDynamicActivity.- Parameters:
activity- The activity context to be used.bottomSheetState- The state to be set.
-
findViewById
Try to find view for the supplied view id.- Parameters:
view- The view to be used.viewId- The view id to be found.- Returns:
- The view for the supplied view id.
-
setTransitionName
Sets the transition name for the supplied view.- Parameters:
view- The view to be used.name- The transition name to be set.
-
setTransitionResultCode
Sets the transition result code for theDynamicActivity.- Parameters:
activity- The activity context to be used.transitionResultCode- The transition result code to be set.
-
setTransitionPosition
Sets the transition position for theDynamicActivity.- Parameters:
activity- The activity context to be used.transitionPosition- The transition position to be set.
-
addSearchViewTextChangedListener
public static void addSearchViewTextChangedListener(@Nullable Context activity, @Nullable TextWatcher textWatcher) Adds the text watcher to listen search view text changes for theDynamicActivity.- Parameters:
activity- The activity context to be used.textWatcher- The search listener to be added.
-
removeSearchViewTextChangedListener
public static void removeSearchViewTextChangedListener(@Nullable Context activity, @Nullable TextWatcher textWatcher) Removes the text watcher from the search view to stop listening text changes for theDynamicActivity.- Parameters:
activity- The activity context to be used.textWatcher- The search listener to be removed.
-
expandSearchView
Expand search view to start searching for theDynamicActivity.- Parameters:
activity- The activity context to be used.requestSoftInput-trueto request the soft input keyboard.
-
collapseSearchView
Collapse search view to stop searching for theDynamicActivity.- Parameters:
activity- The activity context to be used.
-
isSearchViewExpanded
Checks whether the search view is expanded for theDynamicActivity.- Parameters:
activity- The activity context to be used.- Returns:
trueif search view is expanded.
-
restoreSearchViewState
Restore the search view state after the configuration change for theDynamicActivity.- Parameters:
activity- The activity context to be used.
-
addHeader
public static void addHeader(@Nullable Context activity, @Nullable View view, boolean removePrevious, boolean animate) Add header view just below the app bar for theDynamicActivity.Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check
DynamicViewPagerFragmentto add the tabs automatically.- Parameters:
activity- The activity context to be used.view- The view to be added in the header frame.removePrevious-trueto remove the previously added views.animate-trueto animate the changes.
-
addHeader
public static void addHeader(@Nullable Context activity, @Nullable View view, boolean removePrevious) Add header view just below the app bar for theDynamicActivity.Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check
DynamicViewPagerFragmentto add the tabs automatically.- Parameters:
activity- The activity context to be used.view- The view to be added in the header frame.removePrevious-trueto remove the previously added views.
-
addHeader
public static void addHeader(@Nullable Context activity, @LayoutRes int layoutRes, boolean removePrevious, boolean animate) Add header view just below the app bar for theDynamicActivity.Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check
DynamicViewPagerFragmentto add the tabs automatically.- Parameters:
activity- The activity context to be used.layoutRes- The layout resource to be added in the header frame.removePrevious-trueto remove the previously added views.animate-trueto animate the changes.
-
addHeader
public static void addHeader(@Nullable Context activity, @LayoutRes int layoutRes, boolean removePrevious) Add header view just below the app bar for theDynamicActivity.Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check
DynamicViewPagerFragmentto add the tabs automatically.- Parameters:
activity- The activity context to be used.layoutRes- The layout resource to be added in the header frame.removePrevious-trueto remove the previously added views.
-
addBottomSheet
public static void addBottomSheet(@Nullable Context activity, @Nullable View view, boolean removePrevious) Add view in the bottom sheet frame layout for theDynamicActivity.- Parameters:
activity- The activity context to be used.view- The view to be added in the bottom sheet.removePrevious-trueto remove the previously added views.
-
addBottomSheet
public static void addBottomSheet(@Nullable Context activity, @LayoutRes int layoutRes, boolean removePrevious) Add view in the bottom sheet frame layout for theDynamicActivity.- Parameters:
activity- The activity context to be used.layoutRes- The layout resource to be added in the bottom sheet.removePrevious-trueto remove the previously added views.
-
startMotionActivityFromFragment
public static void startMotionActivityFromFragment(@Nullable Context activity, @NonNull Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options, boolean finish, boolean afterTransition) Called by Fragment.startActivityForResult() to implement its behavior for theDynamicActivity.It will allow
Bundleoptions ifDynamicMotion.isMotion()is enabled.- Parameters:
activity- The activity context to be used.fragment- The calling fragment.intent- The intent to be used.requestCode- The request code to be set.options- The intent to be set.finish-trueto finish calling activity.afterTransition-trueto finish the calling activity after transition.
-
startMotionActivityFromFragment
public static void startMotionActivityFromFragment(@Nullable Context activity, @NonNull Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options) Called by Fragment.startActivityForResult() to implement its behavior for theDynamicActivity.It will allow
Bundleoptions ifDynamicMotion.isMotion()is enabled.- Parameters:
activity- The activity context to be used.fragment- The calling fragment.intent- The intent to be used.requestCode- The request code to be set.options- The intent to be set.
-
onPageScrolled
public static void onPageScrolled(@Nullable ViewPager.OnPageChangeListener pager, int position, float positionOffset, @Px int positionOffsetPixels) CallViewPager.OnPageChangeListener.onPageScrolled(int, float, int)method for theViewPager.- Parameters:
pager- The view pager to be used.position- The position index of the first page currently being displayed.Page position+1 will be visible if positionOffset is nonzero.
positionOffset- The value from [0, 1) indicating the offset from the page at position.positionOffsetPixels- The value in pixels indicating the offset from position.
-
onPageSelected
CallViewPager.OnPageChangeListener.onPageSelected(int)method for theViewPager.- Parameters:
pager- The view pager to be used.position- Position index of the new selected page.
-
onPageScrollStateChanged
public static void onPageScrollStateChanged(@Nullable ViewPager.OnPageChangeListener pager, int state) CallView.onScreenStateChanged(int)method for theViewPager.- Parameters:
pager- The view pager to be used.state- The new scroll state.- See Also:
-
getAppShortcutIcon
@Nullable public static Icon getAppShortcutIcon(@NonNull Context context, @DrawableRes int drawableRes, @IdRes int backgroundId, @IdRes int foregroundId, boolean theme) Returns the app shortcut icon according to the dynamic theme.- Parameters:
context- The context to be used.drawableRes- The drawable resource to be used.backgroundId- The background id to be used.foregroundId- The foreground id to be used.theme-trueto useTheme.ColorType.PRIMARYas background.- Returns:
- The app shortcut icon according to the dynamic theme.
-