PkRSS icon indicating copy to clipboard operation
PkRSS copied to clipboard

pullImage from <description> did not work every time

Open GerhardPue opened this issue 8 years ago • 0 comments

it works fine if the description looks like

<description><![CDATA[<img width="150" height="150" src="https://pic150x150.jpg" ]]></description>

but it ditnt work if

<description><![CDATA[	<div>
	<a href...... > <img src="https://pic150x150.jpg" /></a> 
</div>.................... ]]></description>

to you have e solution for changing Rss2Parser

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 "";
    }

GerhardPue avatar Jul 25 '17 17:07 GerhardPue