|
5 | 5 | import android.text.SpannableStringBuilder;
|
6 | 6 | import android.widget.TextView;
|
7 | 7 |
|
| 8 | +import org.jsoup.Jsoup; |
| 9 | +import org.jsoup.nodes.Document; |
| 10 | +import org.jsoup.nodes.Element; |
| 11 | +import org.jsoup.select.Elements; |
| 12 | + |
8 | 13 | import me.ghui.v2er.general.Vtml;
|
9 | 14 | import me.ghui.v2er.module.imgviewer.ImagesInfo;
|
10 | 15 | import me.ghui.v2er.network.APIService;
|
11 | 16 | import me.ghui.v2er.util.ScaleUtils;
|
| 17 | +import me.ghui.v2er.util.Utils; |
12 | 18 |
|
13 | 19 |
|
14 | 20 | /**
|
@@ -77,13 +83,31 @@ public RichTextConfig supportUrlClick(boolean supportUrlClick) {
|
77 | 83 | return this;
|
78 | 84 | }
|
79 | 85 |
|
| 86 | + private Document parseCfEmail(String sourceText) { |
| 87 | + Document sourceDocument = Jsoup.parseBodyFragment(sourceText); |
| 88 | + Elements cfElements = sourceDocument.select("a"); |
| 89 | + for (Element cfElement : cfElements) { |
| 90 | + String cfEmail = cfElement.attr("data-cfemail"); |
| 91 | + String cfHref = cfElement.attr("href"); |
| 92 | + System.out.println(cfEmail); |
| 93 | + if (!cfEmail.isEmpty()) { |
| 94 | + String email = Utils.cfDecodeEmail(cfEmail.replaceAll("\"", "")); |
| 95 | + cfElement.text(email); |
| 96 | + cfElement.removeAttr("data-cfemail"); |
| 97 | + cfElement.attr("href", "mailto:"+email); |
| 98 | + } |
| 99 | +// System.out.println(cfElement); |
| 100 | + } |
| 101 | + return sourceDocument; |
| 102 | + } |
| 103 | + |
80 | 104 | public void into(TextView textView) {
|
81 | 105 | if (!noImg && mImageGetter == null) {
|
82 | 106 | mImageHolder = new ImageHolder(textView, maxSize, mLoadingDrawable, mLoaderrorDrawable);
|
83 | 107 | mImageGetter = new GlideImageGetter(textView, mImageHolder);
|
84 | 108 | }
|
85 | 109 | if (sourceText == null) sourceText = "";
|
86 |
| - SpannableStringBuilder spanned = (SpannableStringBuilder) Html.fromHtml(sourceText, mImageGetter, mTagHandler); |
| 110 | + SpannableStringBuilder spanned = (SpannableStringBuilder) Html.fromHtml(parseCfEmail(sourceText).toString(), mImageGetter, mTagHandler); |
87 | 111 | CharSequence content = Vtml.removePadding(spanned);
|
88 | 112 | textView.setText(content);
|
89 | 113 | ImagesInfo.Images images = APIService.fruit().fromHtml(sourceText, ImagesInfo.Images.class);
|
|
0 commit comments