public class ThemeHelper
extends java.lang.Object
Constructor and Description |
---|
ThemeHelper(android.content.Context context,
int globalTheme,
int phoneTheme,
int tabletTheme)
Creates a new helper class, which allows to retrieve resources, depending on a tab switcher's
theme.
|
Modifier and Type | Method and Description |
---|---|
int |
getColor(Layout layout,
int resourceId)
Returns the color, which corresponds to a specific theme attribute, regarding the theme,
which is used when using a specific layout.
|
android.content.res.ColorStateList |
getColorStateList(Layout layout,
int resourceId)
Returns the color state list, which corresponds to a specific theme attribute, regarding the
theme, which is used when using a specific layout.
|
android.graphics.drawable.Drawable |
getDrawable(Layout layout,
int resourceId)
Returns the drawable, which corresponds to a specific theme attribute, regarding the
theme, which is used when using a specific layout.
|
int |
getInteger(Layout layout,
int resourceId,
int defaultValue)
Returns the integer value, which corresponds to a specific theme attribute, regarding the
theme, which is used when using a specific layout.
|
int |
getResourceId(Layout layout,
int resourceId,
int defaultValue)
Returns the resource id, which corresponds to a specific theme attribute, regarding the
theme, which is used when using a specific layout.
|
java.lang.CharSequence |
getText(Layout layout,
int resourceId)
Returns the text, which corresponds to a specific theme attribute, regarding the theme, which
is used when using a specific layout.
|
int |
getThemeResourceId(Layout layout)
Returns the resource id of the theme, which is used when using a specific layout.
|
public ThemeHelper(@NonNull android.content.Context context, int globalTheme, int phoneTheme, int tabletTheme)
context
- The context, which is used by the tab switcher, as an instance of the class Context
. The context may not be nullglobalTheme
- The resource id of the theme, which should be used regardless of the used layout, as
an Integer
value or 0, if the theme is not specifiedphoneTheme
- The resource id of the theme, which should be used, when using the smartphone layout,
as an Integer
value or 0, if the theme is not specifiedtabletTheme
- The resource id of the theme, which should be used, when using the tablet layout, as
an Integer
value or 0, if the theme is not specifiedpublic final int getThemeResourceId(@NonNull Layout layout)
layout
- The layout as a value of the enum Layout
. The layout may not be nullInteger
valuepublic int getColor(@NonNull Layout layout, @AttrRes int resourceId)
layout
- The layout as a value of the enum Layout
. The layout may not be nullresourceId
- The resource id of the theme attribute, the color should be obtained from, as an
Integer
value. The resource id must correspond to a valid theme attributeInteger
valuepublic android.content.res.ColorStateList getColorStateList(@NonNull Layout layout, @AttrRes int resourceId)
layout
- The layout as a value of the enum Layout
. The layout may not be nullresourceId
- The resource id of the theme attribute, the color state list should be obtained from,
as an Integer
value. The resource id must correspond to a valid theme
attributeColorStateList
public android.graphics.drawable.Drawable getDrawable(@NonNull Layout layout, @AttrRes int resourceId)
layout
- The layout as a value of the enum Layout
. The layout may not be nullresourceId
- The resource id of the theme attribute, the drawable should be obtained from, as an
Integer
value. The resource id must correspond to a valid theme attributeColorStateList
public java.lang.CharSequence getText(@NonNull Layout layout, @AttrRes int resourceId)
layout
- The layout as a value of the enum Layout
. The layout may not be nullresourceId
- The resource id of the theme attribute, the text should be obtained from, as an
Integer
value. The resource id must correspond to a valid theme attributeCharSequence
public int getResourceId(@NonNull Layout layout, @AttrRes int resourceId, int defaultValue)
layout
- The layout as a value of the enum Layout
. The layout may not be nullresourceId
- The resource id of the theme attribute, the resource id should be obtained from, as
an Integer
value. The resource id must correspond to a valid theme attributedefaultValue
- The default value, which should be returned, if the given resource id is invalid, as
an Integer
valueInteger
valuepublic int getInteger(@NonNull Layout layout, @AttrRes int resourceId, int defaultValue)
layout
- The layout as a value of the enum Layout
. The layout may not be nullresourceId
- The resource id of the theme attribute, the integer value should be obtained from, as
an Integer
value. The resource id must correspond to a valid theme attributedefaultValue
- The default value, which should be returned, if the given resource id is invalid, as
an Integer
valueInteger
value