private void init(Context context) { colorPreferences = new ColorPreferences(context); typeface = RobotoTypefaceManager.obtainTypeface( context, new FontPreferences(context).getFontTypeComment().getTypeface()); TypedValue typedValue = new TypedValue(); Resources.Theme theme = context.getTheme(); theme.resolveAttribute(R.attr.font, typedValue, true); textColor = typedValue.data; TypedValue fontSizeTypedValue = new TypedValue(); theme.resolveAttribute(R.attr.font_commentbody, fontSizeTypedValue, true); TypedArray a = context.obtainStyledAttributes( fontSizeTypedValue.data, new int[] {R.attr.font_commentbody}); fontSize = a.getDimensionPixelSize(0, -1); }
public void ParseTextWithLinksTextViewComment( String rawHTML, final SpoilerRobotoTextView comm, final Activity c, final String subreddit) { if (rawHTML.isEmpty()) { return; } this.c = c; Typeface typeface = RobotoTypefaceManager.obtainTypeface( c, new FontPreferences(c).getFontTypeComment().getTypeface()); comm.setTypeface(typeface); rawHTML = rawHTML .replace("<", "<") .replace(">", ">") .replace(""", "\"") .replace("'", "'") .replace("&", "&") .replace("<li><p>", "<p>• ") .replace("</li>", "<br>") .replaceAll("<li.*?>", "• ") .replace("<p>", "<div>") .replace("</p>", "</div>") .replace("</del>", "</strike>") .replace("<del>", "<strike>"); if (rawHTML.contains("\n")) { rawHTML = rawHTML.substring(0, rawHTML.lastIndexOf("\n")); } final CharSequence sequence = convertHtmlToCharSequence(rawHTML); comm.setText(sequence, TextView.BufferType.SPANNABLE); comm.setMovementMethod(new TextViewLinkHandler(c, subreddit, sequence)); comm.setLinkTextColor(new ColorPreferences(c).getColor(subreddit)); }