当前位置: 首页>>代码示例>>Java>>正文


Java NotFoundException类代码示例

本文整理汇总了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);
}
 
开发者ID:googlesamples,项目名称:android-WearAccessibilityApp,代码行数:18,代码来源:ZoomImageActivity.java

示例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));
}
 
开发者ID:kkmike999,项目名称:YuiHatano,代码行数:17,代码来源:ShadowResources.java

示例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];
}
 
开发者ID:kkmike999,项目名称:YuiHatano,代码行数:22,代码来源:ShadowResources.java

示例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());
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:19,代码来源:SelectableRoundedImageView.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:19,代码来源:BasicActivity.java

示例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);
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:23,代码来源:TabSwitcher.java

示例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;
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:29,代码来源:TabSwitcherStyle.java

示例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;
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:23,代码来源:TabSwitcherStyle.java

示例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;
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:23,代码来源:TabSwitcherStyle.java

示例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);
        }
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:27,代码来源:ThemeHelper.java

示例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);
        }
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:29,代码来源:ThemeHelper.java

示例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());
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:SelectableRoundedImageView.java

示例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());
    }
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:20,代码来源:SelectableRoundedImageView.java

示例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;
}
 
开发者ID:stven0king,项目名称:Android-Skin-Loader,代码行数:21,代码来源:SkinManager.java

示例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;
}
 
开发者ID:bitbar,项目名称:robotium-extensions,代码行数:19,代码来源:OtherUtils.java


注:本文中的android.content.res.Resources.NotFoundException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。