/** * Try to fetch string resource id from key * This only works if the key is only defined once and value=key */ protected int keyToStringResId(String keyAsString) { return _cu.getResId(ContextUtils.ResType.STRING, keyAsString); }
/** * Checks if all given (textual) ressource ids are available * * @param resType A {@link ResType} * @param resIdsTextual A (textual) identifier to be awaited at R.restype.resIdsTextual * @return True if all given ids are available */ public boolean areRessourcesAvailable(final ResType resType, final String... resIdsTextual) { for (String name : resIdsTextual) { if (getResId(resType, name) == 0) { return false; } } return true; }
/** * Get String by given string ressource identifier (textual) */ public String rstr(String strResKey) { try { return rstr(getResId(ResType.STRING, strResKey)); } catch (Resources.NotFoundException e) { return null; } }
/** * Try to fetch string resource id from key * This only works if the key is only defined once and value=key */ protected int keyToStringResId(Preference preference) { if (preference != null && !TextUtils.isEmpty(preference.getKey())) { return _cu.getResId(ContextUtils.ResType.STRING, preference.getKey()); } return 0; }
/** * Load a markdown file from a {@link RawRes}, prepend each line with {@code prepend} text * and convert markdown to html using {@link SimpleMarkdownParser} */ public String loadMarkdownForTextViewFromRaw(@RawRes int rawMdFile, String prepend) { try { return new SimpleMarkdownParser() .parse(_context.getResources().openRawResource(rawMdFile), prepend, SimpleMarkdownParser.FILTER_ANDROID_TEXTVIEW) .replaceColor("#000001", rcolor(getResId(ResType.COLOR, "accent"))) .removeMultiNewlines().replaceBulletCharacter("*").getHtml(); } catch (IOException e) { e.printStackTrace(); return ""; } }