本文整理汇总了Java中de.mrapp.android.util.ThemeUtil.getResId方法的典型用法代码示例。如果您正苦于以下问题:Java ThemeUtil.getResId方法的具体用法?Java ThemeUtil.getResId怎么用?Java ThemeUtil.getResId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.mrapp.android.util.ThemeUtil
的用法示例。
在下文中一共展示了ThemeUtil.getResId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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));
}
}
}
示例4: obtainButtonBarBackground
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the background of the button bar from the activity's theme.
*/
private void obtainButtonBarBackground() {
try {
setButtonBarBackgroundColor(ThemeUtil.getColor(this, R.attr.buttonBarBackground));
} catch (NotFoundException e) {
int resourceId = ThemeUtil.getResId(this, R.attr.buttonBarBackground, -1);
if (resourceId != -1) {
setButtonBarBackground(resourceId);
} else {
setButtonBarBackground(null);
}
}
}
示例5: obtainNavigationBackground
import de.mrapp.android.util.ThemeUtil; //导入方法依赖的package包/类
/**
* Obtains the background of the navigation from the activity's theme.
*/
private void obtainNavigationBackground() {
try {
setNavigationBackgroundColor(ThemeUtil.getColor(this, R.attr.navigationBackground));
} catch (NotFoundException e) {
int resourceId = ThemeUtil.getResId(this, R.attr.navigationBackground, -1);
if (resourceId != -1) {
setNavigationBackground(resourceId);
} else {
setNavigationBackground(null);
}
}
}