Пример #1
0
  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("&lt;", "<")
            .replace("&gt;", ">")
            .replace("&quot;", "\"")
            .replace("&apos;", "'")
            .replace("&amp;", "&")
            .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));
  }
Пример #2
0
 private void setStyle(SpoilerRobotoTextView textView, String subreddit) {
   textView.setTextColor(textColor);
   textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
   textView.setTypeface(typeface);
   textView.setLinkTextColor(colorPreferences.getColor(subreddit));
 }