chinalwb / Android-Rich-text-Editor

Android Rich Text Editor With customized spans - 富文本编辑器 - Don't miss this one :)
Apache License 2.0
844 stars 167 forks source link

Image is not shown in editor #82

Open tajanthind opened 5 years ago

tajanthind commented 5 years ago

Everything works fine but when i try to add image or video in the editor, it doesn;t show the image or video.

One question: How to I covert html into original text and show it in a textview or arEdittext but without letting user to edit it.

chinalwb commented 5 years ago

Hi, sorry for late response.

I double-tested, image and video work for me, they can be shown in the editor.

For your question, you can use the sample code in AREditor.java to get the Spanned object and set to your TextView.

public void fromHtml(String html) {
        Html.sContext = mContext;
        Html.ImageGetter imageGetter = new AreImageGetter(mContext, this.mAre);
        Html.TagHandler tagHandler = new AreTagHandler();
        Spanned spanned = Html.fromHtml(html, Html.FROM_HTML_SEPARATOR_LINE_BREAK_PARAGRAPH, imageGetter, tagHandler);
        this.mAre.getEditableText().append(spanned); // Here, replace mAre with TextView
    }
tajanthind commented 5 years ago

Thanks for replying sir. I will tell you if this work. I also wanna know that can I upload an image entered by user to firebase and save that url in areditor. And if i can , how do i display the image from url using glide or picasso?

On Mon, Aug 5, 2019, 6:40 PM Rain Liu, notifications@github.com wrote:

Hi, sorry for late response.

I double-tested, image and video work for me, they can be shown in the editor.

For your question, you can use the sample code in AREditor.java to get the Spanned object and set to your TextView.

public void fromHtml(String html) { Html.sContext = mContext; Html.ImageGetter imageGetter = new AreImageGetter(mContext, this.mAre); Html.TagHandler tagHandler = new AreTagHandler(); Spanned spanned = Html.fromHtml(html, Html.FROM_HTML_SEPARATOR_LINE_BREAK_PARAGRAPH, imageGetter, tagHandler); this.mAre.getEditableText().append(spanned); // Here, replace mAre with TextView }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chinalwb/Android-Rich-text-Editor/issues/82?email_source=notifications&email_token=AMO26YLSQKZWGSWQUCE37P3QDARDNA5CNFSM4IJC5SN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3RYNUA#issuecomment-518227664, or mute the thread https://github.com/notifications/unsubscribe-auth/AMO26YNFR5IPPJYEQEZRXK3QDARDNANCNFSM4IJC5SNQ .

chinalwb commented 5 years ago

There's an interface called ImageStrategy. Your work is have your implementation to do upload and probably you get a URL so that you can show the image.