package com.xtremelabs.robolectric.shadows;

import android.text.Html;
import android.text.Spanned;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;

@SuppressWarnings({"UnusedDeclaration"})
@Implements(Html.class)
public class ShadowHtml {

    @Implementation
    public static Spanned fromHtml(String source) {
		if (source == null) {
			/*
			 * Mimic the behavior of the real fromHtml() method. It uses a
			 * StringReader that throws a NullPointerException when a null
			 * string is passed in.
			 */
			throw new NullPointerException();
		}
        return new SpannedThatActsLikeString(source);
    }

    private static class SpannedThatActsLikeString implements Spanned {
        String source;

        private SpannedThatActsLikeString(String source) {
            this.source = source;
        }

        @Override
        public <T> T[] getSpans(int start, int end, Class<T> type) {
            return null;
        }

        @Override
        public int getSpanStart(Object tag) {
            return 0;
        }

        @Override
        public int getSpanEnd(Object tag) {
            return 0;
        }

        @Override
        public int getSpanFlags(Object tag) {
            return 0;
        }

        @Override
        public int nextSpanTransition(int start, int limit, Class type) {
            return 0;
        }

        @Override
        public int length() {
            return source.length();
        }

        @Override
        public char charAt(int i) {
            return source.charAt(i);
        }

        @Override
        public CharSequence subSequence(int i, int i1) {
            return null;
        }

        @Override
        public String toString() {
            return source;
        }

        @Override
        public boolean equals(Object o) {
            return source.equals(o);
        }

        @Override
        public int hashCode() {
            return source != null ? source.hashCode() : 0;
        }
    }
}

@@ -64,16 +64,60 @@
 t.Html;%0A
+import android.text.SpannableStringBuilder;%0A
 import a
@@ -416,18 +416,24 @@
 urce) %7B%0A
-%09%09
+        
 if (sour
@@ -450,17 +450,35 @@
 ) %7B%0A
-%09%09%09/*%0A%09%09%09
+            /*%0A            
  * M
@@ -536,19 +536,28 @@
  uses a%0A
-%09%09%09
+            
  * Strin
@@ -615,868 +615,104 @@
 ull%0A
-%09%09%09 * string is passed in.%0A%09%09%09 */%0A%09%09%09throw new NullPointerException();%0A%09%09%7D%0A        return new SpannedThatActsLikeString(source);%0A    %7D%0A%0A    private static class SpannedThatActsLikeString implements Spanned %7B%0A        String source;%0A%0A        private SpannedThatActsLikeString(String source) %7B%0A            this.source = source;%0A        %7D%0A%0A        @Override%0A        public %3CT%3E T%5B%5D getSpans(int start, int end, Class%3CT%3E type) %7B%0A            return null;%0A        %7D%0A%0A        @Override%0A        public int getSpanStart(Object tag) %7B%0A            return 0;%0A        %7D%0A%0A        @Override%0A        public int getSpanEnd(Object tag) %7B%0A            return 0;%0A        %7D%0A%0A        @Override%0A        public int getSpanFlags(Object tag) %7B%0A            return 0;%0A        %7D%0A%0A        @Override%0A        public int nextSpanTransition(int start, int limit, Class type) %7B%0A            return 0
+             * string is passed in.%0A             */%0A            throw new NullPointerException()
 ;%0A  
@@ -715,33 +715,32 @@
 ;%0A        %7D%0A
-%0A
         
 @Override%0A  
@@ -731,625 +731,50 @@
     
-@Override%0A        public int length() %7B%0A            return source.length();%0A        %7D%0A%0A        @Override%0A        public char charAt(int i) %7B%0A            return source.charAt(i);%0A        %7D%0A%0A        @Override%0A        public CharSequence subSequence(int i, int i1) %7B%0A            return null;%0A        %7D%0A%0A        @Override%0A        public String toString() %7B%0A            return source;%0A        %7D%0A%0A        @Override%0A        public boolean equals(Object o) %7B%0A            return source.equals(o);%0A        %7D%0A%0A        @Override%0A        public int hashCode() %7B%0A            return source != null ? source.hashCode() : 0;%0A        %7D
+return new SpannableStringBuilder(source);
 %0A   

Improve Html.fromHtml().