本文整理汇总了Java中de.mrapp.android.util.ThemeUtil类的典型用法代码示例。如果您正苦于以下问题:Java ThemeUtil类的具体用法?Java ThemeUtil怎么用?Java ThemeUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ThemeUtil类属于de.mrapp.android.util包,在下文中一共展示了ThemeUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TabSwitcherDrawable
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Creates a new drawable, which allows to display the number of tabs, which are currently
* contained by a {@link TabSwitcher}.
*
* @param context
* The context, which should be used by the drawable, as an instance of the class {@link
* Context}. The context may not be null
*/
public TabSwitcherDrawable(@NonNull final Context context) {
ensureNotNull(context, "The context may not be null");
Resources resources = context.getResources();
size = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_size);
textSizeNormal =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_normal);
textSizeSmall =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_small);
background = ContextCompat.getDrawable(context, R.drawable.tab_switcher_drawable_background)
.mutate();
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.WHITE);
paint.setTextAlign(Align.CENTER);
paint.setTextSize(textSizeNormal);
paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
label = Integer.toString(0);
int tint = ThemeUtil.getColor(context, android.R.attr.textColorPrimary);
setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
}
示例2: obtainThemeFromThemeAttributes
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Returns the resource id of the theme, which is used when using a specific layout. The theme
* is obtained from a theme's attributes. If the theme is not specified, the
* resource id of the default theme is returned.
*
* @param layout
* The layout as a value of the enum {@link Layout}. The layout may not be null
* @param themeResourceId
* The resource id of the theme, the resource id should be obtained from, as an {@link
* Integer} value or -1, if the global app theme should be used
* @return The resource id of the theme, which is used when using the given layout, as an {@link
* Integer} value
*/
private int obtainThemeFromThemeAttributes(@NonNull final Layout layout,
final int themeResourceId) {
int resourceId = layout == Layout.TABLET ? R.attr.tabSwitcherThemeTablet :
R.attr.tabSwitcherThemePhone;
int result = ThemeUtil.getResId(context, themeResourceId, resourceId, 0);
if (result == 0) {
result = ThemeUtil.getResId(context, R.attr.tabSwitcherThemeGlobal, 0);
if (result == 0) {
result = R.style.TabSwitcher_Light;
}
}
return result;
}
示例3: getColor
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Returns the color, which corresponds to a specific theme attribute, regarding the theme,
* which is used when using a specific layout.
*
* @param layout
* The layout as a value of the enum {@link Layout}. The layout may not be null
* @param resourceId
* The resource id of the theme attribute, the color should be obtained from, as an
* {@link Integer} value. The resource id must correspond to a valid theme attribute
* @return The color, which has been obtained, as an {@link Integer} value
*/
@ColorInt
public int getColor(@NonNull final Layout layout, @AttrRes final int resourceId) {
try {
return ThemeUtil.getColor(context, resourceId);
} catch (NotFoundException e1) {
int themeResourceId = getThemeResourceId(layout);
try {
return ThemeUtil.getColor(context, themeResourceId, resourceId);
} catch (NotFoundException e) {
themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
return ThemeUtil.getColor(context, themeResourceId, resourceId);
}
}
}
示例4: getColorStateList
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Returns the color state list, which corresponds to a specific theme attribute, regarding the
* theme, which is used when using a specific layout.
*
* @param layout
* The layout as a value of the enum {@link Layout}. The layout may not be null
* @param resourceId
* The resource id of the theme attribute, the color state list should be obtained from,
* as an {@link Integer} value. The resource id must correspond to a valid theme
* attribute
* @return The color state list, which has been obtained, as an instance of the class {@link
* ColorStateList}
*/
public ColorStateList getColorStateList(@NonNull final Layout layout,
@AttrRes final int resourceId) {
try {
return ThemeUtil.getColorStateList(context, resourceId);
} catch (NotFoundException e1) {
int themeResourceId = getThemeResourceId(layout);
try {
return ThemeUtil.getColorStateList(context, themeResourceId, resourceId);
} catch (NotFoundException e) {
themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
return ThemeUtil.getColorStateList(context, themeResourceId, resourceId);
}
}
}
示例5: getResourceId
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Returns the resource id, which corresponds to a specific theme attribute, regarding the
* theme, which is used when using a specific layout.
*
* @param layout
* The layout as a value of the enum {@link Layout}. The layout may not be null
* @param resourceId
* The resource id of the theme attribute, the resource id should be obtained from, as
* an {@link Integer} value. The resource id must correspond to a valid theme attribute
* @param defaultValue
* The default value, which should be returned, if the given resource id is invalid, as
* an {@link Integer} value
* @return The resource id, which has been obtained, as an {@link Integer} value
*/
public int getResourceId(@NonNull final Layout layout, @AttrRes final int resourceId,
final int defaultValue) {
int result = ThemeUtil.getResId(context, resourceId, 0);
if (result == 0) {
int themeResourceId = getThemeResourceId(layout);
result = ThemeUtil.getResId(context, themeResourceId, resourceId, 0);
if (result == 0) {
themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
return ThemeUtil.getResId(context, themeResourceId, resourceId, defaultValue);
}
}
return result;
}
示例6: getInteger
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Returns the integer value, which corresponds to a specific theme attribute, regarding the
* theme, which is used when using a specific layout.
*
* @param layout
* The layout as a value of the enum {@link Layout}. The layout may not be null
* @param resourceId
* The resource id of the theme attribute, the integer value should be obtained from, as
* an {@link Integer} value. The resource id must correspond to a valid theme attribute
* @param defaultValue
* The default value, which should be returned, if the given resource id is invalid, as
* an {@link Integer} value
* @return The integer value, which has been obtained, as an {@link Integer} value
*/
public int getInteger(@NonNull final Layout layout, @AttrRes final int resourceId,
final int defaultValue) {
int result = ThemeUtil.getInt(context, resourceId, 0);
if (result == 0) {
int themeResourceId = getThemeResourceId(layout);
result = ThemeUtil.getInt(context, themeResourceId, resourceId, 0);
if (result == 0) {
themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
return ThemeUtil.getInt(context, themeResourceId, resourceId, defaultValue);
}
}
return result;
}
示例7: TabSwitcherDrawable
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Creates a new drawable, which allows to display the number of tabs, which are currently
* contained by a {@link TabSwitcher}.
*
* @param context
* The context, which should be used by the drawable, as an instance of the class {@link
* Context}. The context may not be null
*/
public TabSwitcherDrawable(@NonNull final Context context) {
ensureNotNull(context, "The context may not be null");
Resources resources = context.getResources();
size = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_size);
textSizeNormal =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_normal);
textSizeSmall =
resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_small);
background =
ContextCompat.getDrawable(context, R.drawable.tab_switcher_drawable_background)
.mutate();
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.WHITE);
paint.setTextAlign(Align.CENTER);
paint.setTextSize(textSizeNormal);
paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
label = Integer.toString(0);
int tint = ThemeUtil.getColor(context, android.R.attr.textColorPrimary);
setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
}
示例8: obtainButtonBarBackground
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Obtains the background of the button bar from the activity's current theme.
*/
private void obtainButtonBarBackground() {
try {
int color =
ThemeUtil.getColor(getActivity(), R.attr.restoreDefaultsButtonBarBackground);
setButtonBarBackgroundColor(color);
} catch (NotFoundException e) {
int resourceId = ThemeUtil
.getResId(getActivity(), R.attr.restoreDefaultsButtonBarBackground, -1);
if (resourceId != -1) {
setButtonBarBackground(resourceId);
} else {
setButtonBarBackgroundColor(
ContextCompat.getColor(getActivity(), R.color.button_bar_background_light));
}
}
}
示例9: onCreate
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
@Override
protected final void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
float alpha = ThemeUtil.getFloat(this, android.R.attr.disabledAlpha);
initializeUsernameEditText();
initializePasswordEditText();
initializePasswordRepetitionEditText();
initializeGenderSpinner();
initializeFirstNameEditText();
initializeLastNameEditText();
initializeAdditionalInformationEditText();
initializeValidateButton();
}
示例10: createWindowInsetsListener
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Creates a listener, which allows to apply the window insets to the tab switcher's padding.
*
* @return The listener, which has been created, as an instance of the type {@link
* OnApplyWindowInsetsListener}. The listener may not be nullFG
*/
@NonNull
private OnApplyWindowInsetsListener createWindowInsetsListener() {
return new OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(final View v,
final WindowInsetsCompat insets) {
int left = insets.getSystemWindowInsetLeft();
int top = insets.getSystemWindowInsetTop();
int right = insets.getSystemWindowInsetRight();
int bottom = insets.getSystemWindowInsetBottom();
tabSwitcher.setPadding(left, top, right, bottom);
float touchableAreaTop = top;
if (tabSwitcher.getLayout() == Layout.TABLET) {
touchableAreaTop += getResources()
.getDimensionPixelSize(R.dimen.tablet_tab_container_height);
}
RectF touchableArea = new RectF(left, touchableAreaTop,
getDisplayWidth(MainActivity.this) - right, touchableAreaTop +
ThemeUtil.getDimensionPixelSize(MainActivity.this, R.attr.actionBarSize));
tabSwitcher.addDragGesture(
new SwipeGesture.Builder().setTouchableArea(touchableArea).create());
tabSwitcher.addDragGesture(
new PullDownGesture.Builder().setTouchableArea(touchableArea).create());
return insets;
}
};
}
示例11: initialize
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Initializes the view.
*/
private void initialize() {
drawable = new TabSwitcherDrawable(getContext());
setImageDrawable(drawable);
ViewUtil.setBackground(this,
ThemeUtil.getDrawable(getContext(), R.attr.selectableItemBackgroundBorderless));
setContentDescription(null);
setClickable(true);
setFocusable(true);
}
示例12: getDrawable
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Returns the drawable, which corresponds to a specific theme attribute, regarding the
* theme, which is used when using a specific layout.
*
* @param layout
* The layout as a value of the enum {@link Layout}. The layout may not be null
* @param resourceId
* The resource id of the theme attribute, the drawable should be obtained from, as an
* {@link Integer} value. The resource id must correspond to a valid theme attribute
* @return The color state list, which has been obtained, as an instance of the class {@link
* ColorStateList}
*/
public Drawable getDrawable(@NonNull final Layout layout, @AttrRes final int resourceId) {
try {
return ThemeUtil.getDrawable(context, resourceId);
} catch (NotFoundException e1) {
int themeResourceId = getThemeResourceId(layout);
try {
return ThemeUtil.getDrawable(context, themeResourceId, resourceId);
} catch (NotFoundException e) {
themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
return ThemeUtil.getDrawable(context, themeResourceId, resourceId);
}
}
}
示例13: getText
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Returns the text, which corresponds to a specific theme attribute, regarding the theme, which
* is used when using a specific layout.
*
* @param layout
* The layout as a value of the enum {@link Layout}. The layout may not be null
* @param resourceId
* The resource id of the theme attribute, the text should be obtained from, as an
* {@link Integer} value. The resource id must correspond to a valid theme attribute
* @return The text, which has been obtained, as an instance of the type {@link CharSequence}
*/
public CharSequence getText(@NonNull final Layout layout, @AttrRes final int resourceId) {
try {
return ThemeUtil.getText(context, resourceId);
} catch (NotFoundException e1) {
int themeResourceId = getThemeResourceId(layout);
try {
return ThemeUtil.getText(context, themeResourceId, resourceId);
} catch (NotFoundException e) {
themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
return ThemeUtil.getText(context, themeResourceId, resourceId);
}
}
}
示例14: obtainDividerColor
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Obtains the color of the dividers, which are shown above preference categories, from the
* activity's theme.
*/
private void obtainDividerColor() {
int color;
try {
color = ThemeUtil.getColor(getActivity(), R.attr.dividerColor);
} catch (NotFoundException e) {
color = ContextCompat.getColor(getActivity(), R.color.preference_divider_color_light);
}
setDividerColor(color);
}
示例15: obtainRestoreDefaultsButtonText
import de.mrapp.android.util.ThemeUtil; //导入依赖的package包/类
/**
* Obtains the text of the button, which allows to restore the preferences' default values, from
* the activity's current theme.
*/
private void obtainRestoreDefaultsButtonText() {
CharSequence text;
try {
text = ThemeUtil.getText(getActivity(), R.attr.restoreDefaultsButtonText);
} catch (NotFoundException e) {
text = getText(R.string.restore_defaults_button_text);
}
setRestoreDefaultsButtonText(text);
}