androidx.annotation.AnyRes Java Examples
The following examples show how to use
androidx.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: ShortCutUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 创建桌面快捷方式 * @param className 快捷方式点击 Intent className(class.getName()) * @param name 快捷方式名称 * @param icon 快捷方式图标 * @return {@code true} success, {@code false} fail */ public static boolean addShortcut(final String className, final String name, @AnyRes final int icon) { if (className != null && name != null) { try { // 快捷方式点击 Intent 跳转 Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName(DevUtils.getContext(), className); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); return addShortcut(shortcutIntent, name, icon); } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "addShortcut"); } } return false; }
Example #2
Source File: ResourceUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 获取给定资源标识符的全名 * @param id resource identifier * @return Integer */ public static String getResourceName(@AnyRes final int id) { try { return DevUtils.getContext().getResources().getResourceName(id); } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "getResourceName"); } return null; }
Example #3
Source File: ResourceUtils.java From GeometricWeather with GNU Lesser General Public License v3.0 | 5 votes |
@AnyRes public static int getResId(Context context, String resName, String type) { try { return context.getClassLoader() .loadClass(context.getPackageName() + ".R$" + type) .getField(resName) .getInt(null); } catch (Exception e) { return 0; } }
Example #4
Source File: UIUtils.java From DoraemonKit with Apache License 2.0 | 4 votes |
private static boolean resourceHasPackage(@AnyRes int resid) { return (resid >>> 24) != 0; }
Example #5
Source File: ShortCutUtils.java From DevUtils with Apache License 2.0 | 2 votes |
/** * 创建桌面快捷方式 * @param clazz 快捷方式点击 Intent class * @param name 快捷方式名称 * @param icon 快捷方式图标 * @return {@code true} success, {@code false} fail */ public static boolean addShortcut(final Class clazz, final String name, @AnyRes final int icon) { return (clazz != null) ? addShortcut(clazz.getName(), name, icon) : false; }
Example #6
Source File: ShortCutUtils.java From DevUtils with Apache License 2.0 | 2 votes |
/** * 创建桌面快捷方式 * @param shortcutIntent 快捷方式点击 Intent 跳转 * @param name 快捷方式名称 * @param icon 快捷方式图标 * @return {@code true} success, {@code false} fail */ public static boolean addShortcut(final Intent shortcutIntent, final String name, @AnyRes final int icon) { return addShortcut(shortcutIntent, name, icon, null); }
Example #7
Source File: ImageUtils.java From jellyfin-androidtv with GNU General Public License v2.0 | 2 votes |
/** * A utility to return a URL reference to an image resource * * @param resourceId The id of the image resource * @return The URL of the image resource */ public static String getResourceUrl(@AnyRes int resourceId) { Resources resources = TvApp.getApplication().getApplicationContext().getResources(); return String.format("%s://%s/%s/%s", ContentResolver.SCHEME_ANDROID_RESOURCE, resources.getResourcePackageName(resourceId), resources.getResourceTypeName(resourceId), resources.getResourceEntryName(resourceId)); }