當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。