类androidx.annotation.AnyRes源码实例Demo

下面列出了怎么用androidx.annotation.AnyRes的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: DevUtils   文件: ShortCutUtils.java
/**
 * 创建桌面快捷方式
 * @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;
}
 
源代码2 项目: DevUtils   文件: ResourceUtils.java
/**
 * 获取给定资源标识符的全名
 * @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;
}
 
源代码3 项目: GeometricWeather   文件: ResourceUtils.java
@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;
    }
}
 
源代码4 项目: DoraemonKit   文件: UIUtils.java
private static boolean resourceHasPackage(@AnyRes int resid) {
    return (resid >>> 24) != 0;
}
 
源代码5 项目: DevUtils   文件: ShortCutUtils.java
/**
 * 创建桌面快捷方式
 * @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;
}
 
源代码6 项目: DevUtils   文件: ShortCutUtils.java
/**
 * 创建桌面快捷方式
 * @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);
}
 
源代码7 项目: jellyfin-androidtv   文件: ImageUtils.java
/**
 * 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));
}