private String pullImageLink ( String encoded ) { try { XmlPullParserFactory factory = XmlPullParserFactory . newInstance ( ) ; XmlPullParser xpp = factory . newPullParser ( ) ; xpp . setInput ( new StringReader ( encoded ) ) ; int eventType = xpp . getEventType ( ) ; while ( eventType != XmlPullParser . END_DOCUMENT ) { if ( eventType == XmlPullParser . START_TAG && "img" . equals ( xpp . getName ( ) ) ) { int count = xpp . getAttributeCount ( ) ; for ( int x = 0 ; x < count ; x ++ ) { if ( xpp . getAttributeName ( x ) . equalsIgnoreCase ( "src" ) ) return pattern . matcher ( xpp . getAttributeValue ( x ) ) . replaceAll ( "" ) ; } } eventType = xpp . next ( ) ; } } catch ( Exception e ) { log ( TAG , "Error pulling image link from description!\n" + e . getMessage ( ) , Log . WARN ) ; } return "" ; }
Pulls an image URL from an encoded String .