本文整理汇总了Java中android.content.res.Resources.NotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java NotFoundException类的具体用法?Java NotFoundException怎么用?Java NotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NotFoundException类属于android.content.res.Resources包,在下文中一共展示了NotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zoom_image);
AmbientMode.attachAmbientSupport(this);
// Check if integer was actually given.
if (!(getIntent().hasExtra(getString(R.string.intent_extra_image)))) {
throw new NotFoundException("Expecting extras");
}
// Grab the resource id from extras and set the image resource.
int value = getIntent().getIntExtra(getString(R.string.intent_extra_image), 0);
ImageView expandedImage = findViewById(R.id.expanded_image);
expandedImage.setImageResource(value);
}
示例2: getStringArray
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
@NonNull
public String[] getStringArray(@ArrayRes int id) throws NotFoundException {
Map<Integer, String> idNameMap = getArrayIdTable();
Map<String, List<String>> stringArrayMap = getResourceStringArrayMap();
if (idNameMap.containsKey(id)) {
String name = idNameMap.get(id);
if (stringArrayMap.containsKey(name)) {
List<String> stringList = stringArrayMap.get(name);
return stringList.toArray(new String[0]);
}
}
throw new Resources.NotFoundException("String array resource ID #0x" + Integer.toHexString(id));
}
示例3: getIntArray
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
@NonNull
public int[] getIntArray(@ArrayRes int id) throws NotFoundException {
Map<Integer, String> idNameMap = getArrayIdTable();
Map<String, List<Integer>> intArrayMap = getResourceIntArrayMap();
if (idNameMap.containsKey(id)) {
String name = idNameMap.get(id);
if (intArrayMap.containsKey(name)) {
List<Integer> intList = intArrayMap.get(name);
int[] intArray = new int[intList.size()];
for (int i = 0; i < intList.size(); i++) {
intArray[i] = intList.get(i);
}
return intArray;
}
}
return new int[0];
}
示例4: resolveResource
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
private Drawable resolveResource() {
Resources rsrc = getResources();
if (rsrc == null) {
return null;
}
Drawable d = null;
if (nResource != 0) {
try {
d = rsrc.getDrawable(nResource);
} catch (NotFoundException e) {
// Don't try again.
nResource = 0;
}
}
return SelectableRoundedCornerDrawable.fromDrawable(d, getResources());
}
示例5: showToast
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
public void showToast(String resId, int duration) {
String res = null;
if (TextUtils.empty(resId)) {
resId = "umgr_rcode_fail";
}
try {
res = L10NString.getString(resId);
} catch (NotFoundException e) {
LOG.e(TAG, "[resId:" + resId + "] get string failed(NotFoundException)", e);
}
try {
if (!TextUtils.empty(res)) {
ToastHelper.getInstance().shortOrLongToast((Context) this, res, duration);
}
} catch (NotFoundException e2) {
LOG.e(TAG, "[resId:" + resId + "] show toast failed(NotFoundException)", e2);
}
}
示例6: obtainBackground
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
/**
* Obtains the view's background from a specific typed array.
*
* @param typedArray
* The typed array, the background should be obtained from, as an instance of the class
* {@link TypedArray}. The typed array may not be null
*/
private void obtainBackground(@NonNull final TypedArray typedArray) {
Drawable background = typedArray.getDrawable(R.styleable.TabSwitcher_android_background);
if (background == null) {
try {
background = themeHelper.getDrawable(getLayout(), R.attr.tabSwitcherBackground);
} catch (NotFoundException e) {
background = null;
}
}
if (background != null) {
ViewUtil.setBackground(this, background);
}
}
示例7: getTabIcon
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
/**
* Returns the icon of tabs.
*
* @param tab
* The tab, the icon should be returned for, as an instance of the class {@link Tab} or
* null, if the icon should not be returned for a specific tab
* @return The icon of tabs as an instance of the class {@link Drawable} or null, if no icon is
* set
*/
@Nullable
public final Drawable getTabIcon(@Nullable final Tab tab) {
Drawable icon = tab != null ? tab.getIcon(model.getContext()) : null;
if (icon == null) {
icon = model.getTabIcon();
if (icon == null) {
try {
icon = themeHelper
.getDrawable(tabSwitcher.getLayout(), R.attr.tabSwitcherTabIcon);
} catch (NotFoundException e) {
icon = null;
}
}
}
return icon;
}
示例8: getToolbarTitle
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
/**
* Returns the title of the toolbar, which is shown, when the tab switcher is shown. When using
* the tablet layout, the title corresponds to the primary toolbar.
*
* @return The title of the toolbar, which is shown, when the tab switcher is shown, as an
* instance of the type {@link CharSequence} or null, if no title is set
*/
@Nullable
public final CharSequence getToolbarTitle() {
CharSequence title = model.getToolbarTitle();
if (TextUtils.isEmpty(title)) {
try {
title = themeHelper
.getText(tabSwitcher.getLayout(), R.attr.tabSwitcherToolbarTitle);
} catch (NotFoundException e) {
title = null;
}
}
return title;
}
示例9: getToolbarNavigationIcon
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
/**
* Returns the navigation icon of the toolbar, which is shown, when the tab switcher is shown.
* When using the tablet layout, the icon corresponds to the primary toolbar.
*
* @return The icon of the toolbar, which is shown, when the tab switcher is shown, as an
* instance of the class {@link Drawable} or null, if no icon is set
*/
@Nullable
public final Drawable getToolbarNavigationIcon() {
Drawable icon = model.getToolbarNavigationIcon();
if (icon == null) {
try {
themeHelper.getDrawable(tabSwitcher.getLayout(),
R.attr.tabSwitcherToolbarNavigationIcon);
} catch (NotFoundException e) {
icon = null;
}
}
return icon;
}
示例10: getColor
import android.content.res.Resources.NotFoundException; //导入依赖的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);
}
}
}
示例11: getColorStateList
import android.content.res.Resources.NotFoundException; //导入依赖的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);
}
}
}
示例12: resolveResource
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
private Drawable resolveResource() {
Resources rsrc = getResources();
if (rsrc == null) {
return null;
}
Drawable d = null;
if (this.mResource != 0) {
try {
d = rsrc.getDrawable(this.mResource);
} catch (NotFoundException e) {
Log.w(TAG, "Unable to find resource: " + this.mResource, e);
this.mResource = 0;
}
}
return SelectableRoundedCornerDrawable.fromDrawable(d, getResources());
}
示例13: resolveResource
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
private Drawable resolveResource() {
Resources rsrc = getResources();
if (rsrc == null) {
return null;
}
Drawable d = null;
if (mResource != 0) {
try {
d = rsrc.getDrawable(mResource);
} catch (NotFoundException e) {
// Log.w(TAG, "Unable to find resource: " + mResource, e);
// Don't try again.
mResource = 0;
}
}
return SelectableRoundedCornerDrawable.fromDrawable(d, getResources());
}
示例14: getColor
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
public int getColor(int resId){
int originColor = context.getResources().getColor(resId);
if(mResources == null || isDefaultSkin){
return originColor;
}
String resName = context.getResources().getResourceEntryName(resId);
int trueResId = mResources.getIdentifier(resName, "color", skinPackageName);
int trueColor = 0;
try{
trueColor = mResources.getColor(trueResId);
}catch(NotFoundException e){
e.printStackTrace();
trueColor = originColor;
}
return trueColor;
}
示例15: getDescriptionOrId
import android.content.res.Resources.NotFoundException; //导入依赖的package包/类
private String getDescriptionOrId(View view) {
String result = view.getContentDescription() != null ? view
.getContentDescription().toString() : null;
if (isNullOrEmpty(result)) {
if (view.getId() != View.NO_ID) {
try {
result = String.format("with id: \"%s\"", view.getContext()
.getResources().getResourceEntryName(view.getId()));
} catch (NotFoundException e) {
result = String.format(Locale.ENGLISH, "with id: \"%d\"",
view.getId());
}
}
} else {
result = String.format("\"%s\"", result);
}
return result;
}