@@ -90,8 +90,11 @@ public interface ImageGetter {
9090
9191 interface Callbacks {
9292 void onUseDefaultImage ();
93+
9394 void onImageFailed ();
95+
9496 void onImageLoaded (Drawable drawable );
97+
9598 void onImageLoading (Drawable drawable );
9699 }
97100 }
@@ -106,7 +109,7 @@ public interface TagHandler {
106109 * a tag that it does not know how to interpret.
107110 */
108111 boolean handleTag (boolean opening , String tag , Editable output , OnMediaTappedListener onMediaTappedListener ,
109- Context context , Attributes attributes , int nestingLevel );
112+ Context context , Attributes attributes , int nestingLevel );
110113 }
111114
112115 private Html () {
@@ -183,6 +186,7 @@ class HtmlToSpannedConverter implements ContentHandler, LexicalHandler {
183186 public int unknownTagLevel = 0 ;
184187 public Unknown unknown ;
185188 private boolean insidePreTag = false ;
189+ private boolean insideCodeTag = false ;
186190
187191 private String mSource ;
188192 private UnknownHtmlSpan .OnUnknownHtmlClickListener onUnknownHtmlClickListener ;
@@ -291,12 +295,14 @@ private void handleStartTag(String tag, Attributes attributes, int nestingLevel)
291295 } else if (tag .equalsIgnoreCase ("sub" )) {
292296 start (spannableStringBuilder , TextFormat .FORMAT_SUBSCRIPT , attributes );
293297 } else if (tag .equalsIgnoreCase ("code" )) {
298+ insideCodeTag = true ;
294299 start (spannableStringBuilder , TextFormat .FORMAT_CODE , attributes );
295300 } else {
296301 if (tagHandler != null ) {
297- if (tag .equalsIgnoreCase ("pre" )){
302+ if (tag .equalsIgnoreCase ("pre" )) {
298303 insidePreTag = true ;
299304 }
305+
300306 boolean tagHandled = tagHandler .handleTag (true , tag , spannableStringBuilder , onMediaTappedListener ,
301307 context , attributes , nestingLevel );
302308 if (tagHandled ) {
@@ -369,9 +375,10 @@ private void handleEndTag(String tag, int nestingLevel) {
369375 } else if (tag .equalsIgnoreCase ("sub" )) {
370376 end (spannableStringBuilder , TextFormat .FORMAT_SUBSCRIPT );
371377 } else if (tag .equalsIgnoreCase ("code" )) {
378+ insideCodeTag = false ;
372379 end (spannableStringBuilder , TextFormat .FORMAT_CODE );
373380 } else if (tagHandler != null ) {
374- if (tag .equalsIgnoreCase ("pre" )){
381+ if (tag .equalsIgnoreCase ("pre" )) {
375382 insidePreTag = false ;
376383 }
377384 tagHandler .handleTag (false , tag , spannableStringBuilder , onMediaTappedListener , context , new AztecAttributes (),
@@ -611,7 +618,7 @@ public void characters(char ch[], int start, int length) throws SAXException {
611618 for (int i = 0 ; i < length ; i ++) {
612619 char c = ch [i + start ];
613620
614- if (!insidePreTag && c == ' ' || c == '\n' ) {
621+ if (!insidePreTag && ! insideCodeTag && c == ' ' || c == '\n' ) {
615622 char pred ;
616623 int len = sb .length ();
617624
0 commit comments