android.support.annotation.AnyRes Java Examples
The following examples show how to use
android.support.annotation.AnyRes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourcesHelper.java From AndroidBlueprints with Apache License 2.0 | 6 votes |
/** * get uri to any resource type * * @param resId - resource id * @return - Uri to resource by given id */ public static Uri getUriToResource(@NonNull Activity activity, @AnyRes int resId) { Uri resUri = null; try { /** Return a Resources instance for your application's package. */ Resources res = activity.getResources(); /** * Creates a Uri which parses the given encoded URI string. * @param uriString an RFC 2396-compliant, encoded URI * @throws NullPointerException if uriString is null * @return Uri for this given uri string */ resUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + res.getResourcePackageName(resId) + '/' + res .getResourceTypeName(resId) + '/' + res.getResourceEntryName(resId)); /** return uri */ } catch (Resources.NotFoundException e) { e.printStackTrace(); } return resUri; }
Example #2
Source File: ViewUtils.java From BehaviorCollect with GNU General Public License v3.0 | 5 votes |
/** * 根据资源id获取资源文件名字 --- 简单名称。 * * @param context 上下文 * @param resid 资源id * @return */ public static String getSimpleResourceName(@NonNull Context context, @AnyRes int resid) { String res = ""; if (-1 == resid) return res; try { res = context.getResources().getResourceName(resid); res = res.substring(res.indexOf("/") + 1); } catch (Resources.NotFoundException e) { // e.printStackTrace(); //LogUtils.d("out", "未获取到ResourceName ---id="+resid); } return res; }
Example #3
Source File: ResourceUtil.java From ExoMedia with Apache License 2.0 | 5 votes |
/** * Resolves the reference to an attribute, returning the root resource id. * * @param context The context to use when determining the root id * @param attr The attribute to resolve * @return The resource id pointing to the de-referenced attribute */ @AnyRes public static int getResolvedResourceId(Context context, @AttrRes int attr) { TypedValue typedValue = new TypedValue(); Resources.Theme theme = context.getTheme(); theme.resolveAttribute(attr, typedValue, true); if (typedValue.type == TypedValue.TYPE_REFERENCE) { return typedValue.data; } return typedValue.resourceId; }
Example #4
Source File: Utils.java From external-resources with Apache License 2.0 | 5 votes |
@Nullable public static String getAndroidResourceEntryName(Context context, @AnyRes int resId) { try { return context.getResources().getResourceEntryName(resId); } catch (android.content.res.Resources.NotFoundException e) { return null; } }
Example #5
Source File: ExternalResources.java From external-resources with Apache License 2.0 | 5 votes |
@Nullable private String getApplicationResourceEntryName(@AnyRes int resId) throws IllegalStateException { if (!useApplicationResources) { throw new IllegalStateException( "You have set the useApplicationResources to false, using application resource is an error."); } return Utils.getAndroidResourceEntryName(context, resId); }
Example #6
Source File: NotificationBuilder.java From AlexaAndroid with GNU General Public License v2.0 | 5 votes |
/** * get uri to drawable or any other resource type if u wish * @param context - context * @param drawableId - drawable res id * @return - uri */ public static String getUriToDrawable(@NonNull Context context, @AnyRes int drawableId) { String imageUri = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.getResources().getResourcePackageName(drawableId) + '/' + context.getResources().getResourceTypeName(drawableId) + '/' + context.getResources().getResourceEntryName(drawableId); return imageUri; }
Example #7
Source File: SkinCompatResources.java From Android-skin-support with MIT License | 5 votes |
private void getSkinValue(Context context, @AnyRes int resId, TypedValue outValue, boolean resolveRefs) { if (!isDefaultSkin) { int targetResId = getTargetResId(context, resId); if (targetResId != 0) { mResources.getValue(targetResId, outValue, resolveRefs); return; } } context.getResources().getValue(resId, outValue, resolveRefs); }
Example #8
Source File: ViewUtils.java From BehaviorCollect with GNU General Public License v3.0 | 5 votes |
/** * 根据资源id获取资源文件名字 --- 带包名的全路径。 * * @param context 上下文 * @param resid 资源id * @return */ public static String getResourceName(@NonNull Context context, @AnyRes int resid) { String res = ""; if (-1 == resid) return res; try { res = context.getResources().getResourceName(resid); } catch (Resources.NotFoundException e) { // e.printStackTrace(); //LogUtils.d("out", "未获取到ResourceName ---id="+resid); } return res; }
Example #9
Source File: ResourcesUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static void getValueForDensity(@AnyRes int anyRes, int density, TypedValue outValue, boolean resolveRefs) { if (APILevel.require(15)) Base.getResources().getValueForDensity(anyRes, density, outValue, resolveRefs); else Base.getResources().getValue(anyRes, outValue, resolveRefs); }
Example #10
Source File: IOUtils.java From weMessage with GNU Affero General Public License v3.0 | 4 votes |
public static Uri getUriFromResource(@NonNull Context context, @AnyRes int resId) throws Resources.NotFoundException { Resources res = context.getResources(); Uri resUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + res.getResourcePackageName(resId) + '/' + res.getResourceTypeName(resId) + '/' + res.getResourceEntryName(resId)); return resUri; }
Example #11
Source File: TypedArrayUtils.java From letv with Apache License 2.0 | 4 votes |
@AnyRes public static int getResourceId(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex, @AnyRes int defaultValue) { return a.getResourceId(index, a.getResourceId(fallbackIndex, defaultValue)); }
Example #12
Source File: ResourcesUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static void getValue(@AnyRes int anyRes, TypedValue outValue, boolean resolveRefs) { Base.getResources().getValue(anyRes, outValue, resolveRefs); }
Example #13
Source File: SkinCompatResources.java From Android-skin-support with MIT License | 4 votes |
public static void getValue(Context context, @AnyRes int resId, TypedValue outValue, boolean resolveRefs) { getInstance().getSkinValue(context, resId, outValue, resolveRefs); }
Example #14
Source File: ResourcesUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static String getResourceTypeName(@AnyRes int anyRes) { return Base.getResources().getResourceTypeName(anyRes); }
Example #15
Source File: ResourcesUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static String getResourcePackageName(@AnyRes int anyRes) { return Base.getResources().getResourcePackageName(anyRes); }
Example #16
Source File: ResourcesUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static String getResourceName(@AnyRes int anyRes) { return Base.getResources().getResourceName(anyRes); }
Example #17
Source File: ResourcesUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public static String getResourceEntryName(@AnyRes int anyRes) { return Base.getResources().getResourceEntryName(anyRes); }
Example #18
Source File: GraywaterAdapter.java From Graywater with Apache License 2.0 | 2 votes |
/** * @param model * the model that will be bound. * @return the type of the viewholder. */ @AnyRes int getViewType(U model);