How to load an image into the RTEditor from a link?
I've seen the sample app and some.of the code but I can't or maybe I failed to find how to insert an image into the RTEditor from a url
EDIT : I've scoured around the source code, but I still can't find a method or implementation that could be used. Though, I could download the image and save it into a storage location that I can reference then create an RTImage object out of it, the problem now is how to reference the link used in the actual text I would get from the editor.
Also, is there a way to remove the loading of fonts from the device? I have an app that has multiple fragments and one of those fragments houses the RTEditor. I initialize the RTEditor in the onCreate method so the transition gets stuck for about 1-2 seconds before showing the actual fragment. I can't find any method to "turn off" this the font style feature.
You can't insert images from a url at the moment. Feel free to submit a pull request for that. Android does support only local images in ImageSpan, so you would have to download the image before inserting it into the text. You would extend the RTMediaFactoryImpl (or write a RTMediaFactory from scratch) to implement the download of an image in createImage(String) --> create a custom RTImage object that holds the reference to the local and the remote location. The exported HTML could use the remote image if that's preferred (the RTImage objects just needs to return the according path in getFilePath).
I'm not sure what you mean with "how to reference the link used in the actual text I would get from the editor"? Can you elaborate? When the text is concerted to HTML it would create an img tag and call the getFilePath on the RTImage object. If your RTImage object returns the remote location of the image the HTML img tag would use that one (<img src="http://...).
You can use the FontManager.preLoadFonts(Context) method to asynchronously load the fonts when the app starts up. I call the method from my Application class.
Please don't create an issue with two questions. Makes it hard to close them off or keep them open if needed.
Sorry and thanks for the tips. I'm considering implementing that as your library is the most complete rich editor I have seen. And quite fast when the fonts have been preloaded.
Also yes I am referring do the remote location of the image.
I was facing the same issue. My source was originally in HTML, and the image URLs were in the src attributes. I eventually figured out a way to parse out the URL and download the image then substitute the local image path for the URL in the src attribute, then passing the modifies version of HTML content into RTEditor. RTEditor successfully recognized the localized paths in the img src attributes and displayed the image this way. Perhaps this HTML approach would work as well?
Will this link be of any help: https://medium.com/@rajeefmk/android-textview-and-image-loading-from-url-part-1-a7457846abb6 ?