java类android.content.res.Resources.NotFoundException的实例源码

ZoomImageActivity.java 文件源码 项目:android-WearAccessibilityApp 阅读 36 收藏 0 点赞 0 评论 0
@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);
}
ShadowResources.java 文件源码 项目:YuiHatano 阅读 39 收藏 0 点赞 0 评论 0
@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));
}
ShadowResources.java 文件源码 项目:YuiHatano 阅读 40 收藏 0 点赞 0 评论 0
@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];
}
SelectableRoundedImageView.java 文件源码 项目:BBSSDK-for-Android 阅读 47 收藏 0 点赞 0 评论 0
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());
}
BasicActivity.java 文件源码 项目:letv 阅读 42 收藏 0 点赞 0 评论 0
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);
    }
}
TabSwitcher.java 文件源码 项目:ChromeLikeTabSwitcher 阅读 41 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
TabSwitcherStyle.java 文件源码 项目:ChromeLikeTabSwitcher 阅读 36 收藏 0 点赞 0 评论 0
/**
 * 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;
}
TabSwitcherStyle.java 文件源码 项目:ChromeLikeTabSwitcher 阅读 37 收藏 0 点赞 0 评论 0
/**
 * 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;
}
TabSwitcherStyle.java 文件源码 项目:ChromeLikeTabSwitcher 阅读 34 收藏 0 点赞 0 评论 0
/**
 * 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;
}
ThemeHelper.java 文件源码 项目:ChromeLikeTabSwitcher 阅读 44 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
ThemeHelper.java 文件源码 项目:ChromeLikeTabSwitcher 阅读 36 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
SelectableRoundedImageView.java 文件源码 项目:boohee_v5.6 阅读 46 收藏 0 点赞 0 评论 0
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());
}
SelectableRoundedImageView.java 文件源码 项目:sealtalk-android-master 阅读 44 收藏 0 点赞 0 评论 0
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());
    }
SkinManager.java 文件源码 项目:Android-Skin-Loader 阅读 37 收藏 0 点赞 0 评论 0
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;
}
SelectableRoundedImageView.java 文件源码 项目:rongyunDemo 阅读 41 收藏 0 点赞 0 评论 0
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());
    }
ShadowResources.java 文件源码 项目:KBUnitTest 阅读 40 收藏 0 点赞 0 评论 0
@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));
}
ShadowResources.java 文件源码 项目:KBUnitTest 阅读 31 收藏 0 点赞 0 评论 0
@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];
}
OtherUtils.java 文件源码 项目:robotium-extensions 阅读 43 收藏 0 点赞 0 评论 0
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;
}
SelectableRoundedImageView.java 文件源码 项目:RongCloudJcenter 阅读 56 收藏 0 点赞 0 评论 0
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());
    }
SelectableRoundedImageView.java 文件源码 项目:IMKBaseFrameworkLibrary 阅读 39 收藏 0 点赞 0 评论 0
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());
}
Uploader.java 文件源码 项目:Cirrus 阅读 37 收藏 0 点赞 0 评论 0
/**
 * Updates the view associated to the activity after the finish of an operation
 * trying create a new folder
 *
 * @param operation     Creation operation performed.
 * @param result        Result of the creation.
 */
private void onCreateFolderOperationFinish(CreateFolderOperation operation,
                                           RemoteOperationResult result) {
    if (result.isSuccess()) {
        dismissLoadingDialog();
        populateDirectoryList();
    } else {
        dismissLoadingDialog();
        try {
            Toast msg = Toast.makeText(this,
                    ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                    Toast.LENGTH_LONG);
            msg.show();

        } catch (NotFoundException e) {
            Log_OC.e(TAG, "Error while trying to show fail message " , e);
        }
    }
}
FolderPickerActivity.java 文件源码 项目:Cirrus 阅读 38 收藏 0 点赞 0 评论 0
/**
 * Updates the view associated to the activity after the finish of an operation trying
 * to create a new folder.
 *
 * @param operation     Creation operation performed.
 * @param result        Result of the creation.
 */
private void onCreateFolderOperationFinish(
        CreateFolderOperation operation, RemoteOperationResult result
) {

    if (result.isSuccess()) {
        refreshListOfFilesFragment();
    } else {
        try {
            Toast msg = Toast.makeText(FolderPickerActivity.this,
                    ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                    Toast.LENGTH_LONG);
            msg.show();

        } catch (NotFoundException e) {
            Log_OC.e(TAG, "Error while trying to show fail message " , e);
        }
    }
}
FileDisplayActivity.java 文件源码 项目:Cirrus 阅读 32 收藏 0 点赞 0 评论 0
/**
 * Updates the view associated to the activity after the finish of an operation trying to move a
 * file.
 *
 * @param operation Move operation performed.
 * @param result    Result of the move operation.
 */
private void onMoveFileOperationFinish(MoveFileOperation operation,
                                       RemoteOperationResult result) {
    if (result.isSuccess()) {
        dismissLoadingDialog();
        refreshListOfFilesFragment();
    } else {
        dismissLoadingDialog();
        try {
            Toast msg = Toast.makeText(FileDisplayActivity.this,
                    ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                    Toast.LENGTH_LONG);
            msg.show();

        } catch (NotFoundException e) {
            Log_OC.e(TAG, "Error while trying to show fail message ", e);
        }
    }
}
FileDisplayActivity.java 文件源码 项目:Cirrus 阅读 37 收藏 0 点赞 0 评论 0
/**
 * Updates the view associated to the activity after the finish of an operation trying to copy a
 * file.
 *
 * @param operation Copy operation performed.
 * @param result    Result of the copy operation.
 */
private void onCopyFileOperationFinish(CopyFileOperation operation, RemoteOperationResult result) {
    if (result.isSuccess()) {
        dismissLoadingDialog();
        refreshListOfFilesFragment();
    } else {
        dismissLoadingDialog();
        try {
            Toast msg = Toast.makeText(FileDisplayActivity.this,
                    ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                    Toast.LENGTH_LONG);
            msg.show();

        } catch (NotFoundException e) {
            Log_OC.e(TAG, "Error while trying to show fail message ", e);
        }
    }
}
FileDisplayActivity.java 文件源码 项目:Cirrus 阅读 38 收藏 0 点赞 0 评论 0
/**
 * Updates the view associated to the activity after the finish of an operation trying create a
 * new folder
 *
 * @param operation Creation operation performed.
 * @param result    Result of the creation.
 */
private void onCreateFolderOperationFinish(CreateFolderOperation operation,
                                           RemoteOperationResult result) {
    if (result.isSuccess()) {
        dismissLoadingDialog();
        refreshListOfFilesFragment();
    } else {
        dismissLoadingDialog();
        try {
            Toast msg = Toast.makeText(FileDisplayActivity.this,
                    ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                    Toast.LENGTH_LONG);
            msg.show();

        } catch (NotFoundException e) {
            Log_OC.e(TAG, "Error while trying to show fail message ", e);
        }
    }
}
MainActivity.java 文件源码 项目:TowerCollector 阅读 29 收藏 0 点赞 0 评论 0
private void displayUploadResultDialog(Bundle extras) {
    int descriptionId = extras.getInt(UploaderService.INTENT_KEY_RESULT_DESCRIPTION);
    try {
        String descriptionContent = getString(descriptionId);
        Log.d("displayUploadResultDialog(): Received extras: %s", descriptionId);
        // display dialog
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setCanceledOnTouchOutside(true);
        alertDialog.setCancelable(true);
        alertDialog.setTitle(R.string.uploader_result_dialog_title);
        alertDialog.setMessage(descriptionContent);
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
            }
        });
        alertDialog.show();
    } catch (NotFoundException ex) {
        Log.w("displayUploadResultDialog(): Invalid string id received with intent extras: %s", descriptionId);
        MyApplication.getAnalytics().sendException(ex, Boolean.FALSE);
        ACRA.getErrorReporter().handleSilentException(ex);
    }
}
RoundedImageView.java 文件源码 项目:AndroidMaterialDesign 阅读 48 收藏 0 点赞 0 评论 0
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());
}
SelectableRoundedImageView.java 文件源码 项目:sealtalk-android 阅读 45 收藏 0 点赞 0 评论 0
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());
    }
GifTextView.java 文件源码 项目:android-gif-drawable-for-Eclipse 阅读 42 收藏 0 点赞 0 评论 0
@TargetApi(Build.VERSION_CODES.LOLLIPOP) //Resources#getDrawable(int, Theme)
@SuppressWarnings("deprecation") //Resources#getDrawable(int)
private Drawable getGifOrDefaultDrawable(int resId) {
    if (resId == 0) {
        return null;
    }
    final Resources resources = getResources();
    if (!isInEditMode() && "drawable".equals(resources.getResourceTypeName(resId))) {
        try {
            return new GifDrawable(resources, resId);
        } catch (IOException | NotFoundException ignored) {
            // ignored
        }
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return resources.getDrawable(resId, getContext().getTheme());
    } else {
        return resources.getDrawable(resId);
    }
}
SkinManager.java 文件源码 项目:themePlugin 阅读 38 收藏 0 点赞 0 评论 0
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;
}


问题


面经


文章

微信
公众号

扫码关注公众号