Search in sources :

Example 1 with DrawableGetter

use of com.fastaccess.provider.timeline.handler.drawable.DrawableGetter in project FastHub by k0shk0sh.

the class DrawableHandler method handleTagNode.

@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end) {
    String src = node.getAttributeByName("src");
    if (!InputHelper.isEmpty(src)) {
        if (!PrefGetter.isAutoImageDisabled()) {
            builder.append("");
            if (isNull())
                return;
            builder.append("\n");
            DrawableGetter imageGetter = new DrawableGetter(textView, width);
            builder.setSpan(new ImageSpan(imageGetter.getDrawable(src)), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
            builder.setSpan(new CenterSpan(), start, builder.length(), SPAN_EXCLUSIVE_EXCLUSIVE);
            builder.append("\n");
        } else {
            builder.append(SpannableBuilder.builder().clickable("Image", v -> SchemeParser.launchUri(v.getContext(), src)));
            builder.append("\n");
        }
    }
}
Also used : DrawableGetter(com.fastaccess.provider.timeline.handler.drawable.DrawableGetter) SPAN_EXCLUSIVE_EXCLUSIVE(android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) ImageSpan(android.text.style.ImageSpan) InputHelper(com.fastaccess.helper.InputHelper) CenterSpan(net.nightwhistler.htmlspanner.spans.CenterSpan) SchemeParser(com.fastaccess.provider.scheme.SchemeParser) DrawableGetter(com.fastaccess.provider.timeline.handler.drawable.DrawableGetter) SpannableBuilder(com.fastaccess.ui.widgets.SpannableBuilder) SpannableStringBuilder(android.text.SpannableStringBuilder) TextView(android.widget.TextView) PrefGetter(com.fastaccess.helper.PrefGetter) TagNodeHandler(net.nightwhistler.htmlspanner.TagNodeHandler) TagNode(org.htmlcleaner.TagNode) AllArgsConstructor(lombok.AllArgsConstructor) CenterSpan(net.nightwhistler.htmlspanner.spans.CenterSpan) ImageSpan(android.text.style.ImageSpan)

Aggregations

SpannableStringBuilder (android.text.SpannableStringBuilder)1 SPAN_EXCLUSIVE_EXCLUSIVE (android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)1 ImageSpan (android.text.style.ImageSpan)1 TextView (android.widget.TextView)1 InputHelper (com.fastaccess.helper.InputHelper)1 PrefGetter (com.fastaccess.helper.PrefGetter)1 SchemeParser (com.fastaccess.provider.scheme.SchemeParser)1 DrawableGetter (com.fastaccess.provider.timeline.handler.drawable.DrawableGetter)1 SpannableBuilder (com.fastaccess.ui.widgets.SpannableBuilder)1 AllArgsConstructor (lombok.AllArgsConstructor)1 TagNodeHandler (net.nightwhistler.htmlspanner.TagNodeHandler)1 CenterSpan (net.nightwhistler.htmlspanner.spans.CenterSpan)1 TagNode (org.htmlcleaner.TagNode)1