I'm creating an app with rss feed and when I want to download a thumbnail of a post, I have to use jsoup parser. Here is a code of how I'm doing that:
String link;
public String getLink() {
return link;
}
public void setLink(String link) {
String url = getImageURL(link);
this.link = url;
}
public String getImageURL(String url) {
Document doc = null;
try {
doc = Jsoup.connect(url).get();
}
catch (IOException e) {
e.printStackTrace();
}
Element masthead = doc.select("div.post-image").select("img[src~=(?i)\\.(png|jpe?g)]").first();
url = masthead.absUrl("src");
return url;
}
And after doing "Jsoup.connect(url).get();" opening an app lasts so long and in logcat I can see this:
06-24 12:16:03.734 2838-2838/pl.dariusz.app I/Choreographer: Skipped 34 frames! The application may be doing too much work on its main thread.
What can I do to get rid of this statement and to speed up an app?