use of io.plaidapp.data.api.dribbble.model.Images in project plaid by nickbutcher.
the class DribbbleSearchConverter method parseShot.
private static Shot parseShot(Element element, SimpleDateFormat dateFormat) {
final Element descriptionBlock = element.select("a.dribbble-over").first();
// API responses wrap description in a <p> tag. Do the same for consistent display.
String description = descriptionBlock.select("span.comment").text().trim();
if (!TextUtils.isEmpty(description)) {
description = "<p>" + description + "</p>";
}
String imgUrl = element.select("img").first().attr("src");
if (imgUrl.contains("_teaser.")) {
imgUrl = imgUrl.replace("_teaser.", ".");
}
Date createdAt = null;
try {
createdAt = dateFormat.parse(descriptionBlock.select("em.timestamp").first().text());
} catch (ParseException e) {
}
return new Shot.Builder().setId(Long.parseLong(element.id().replace("screenshot-", ""))).setHtmlUrl(HOST + element.select("a.dribbble-link").first().attr("href")).setTitle(descriptionBlock.select("strong").first().text()).setDescription(description).setImages(new Images(null, imgUrl, null)).setAnimated(element.select("div.gif-indicator").first() != null).setCreatedAt(createdAt).setLikesCount(Long.parseLong(element.select("li.fav").first().child(0).text().replaceAll(",", ""))).setCommentsCount(Long.parseLong(element.select("li.cmnt").first().child(0).text().replaceAll(",", ""))).setViewsCount(Long.parseLong(element.select("li.views").first().child(0).text().replaceAll(",", ""))).setUser(parsePlayer(element.select("h2").first())).build();
}
use of io.plaidapp.data.api.dribbble.model.Images in project sbt-android by scala-android.
the class DribbbleSearch method parseShot.
private static Shot parseShot(Element element, SimpleDateFormat dateFormat) {
Element descriptionBlock = element.select("a.dribbble-over").first();
// API responses wrap description in a <p> tag. Do the same for consistent display.
String description = descriptionBlock.select("span.comment").text().trim();
if (!TextUtils.isEmpty(description)) {
description = "<p>" + description + "</p>";
}
String imgUrl = element.select("img").first().attr("src");
if (imgUrl.contains("_teaser.")) {
imgUrl = imgUrl.replace("_teaser.", ".");
}
Date createdAt = null;
try {
createdAt = dateFormat.parse(descriptionBlock.select("em.timestamp").first().text());
} catch (ParseException e) {
}
return new Shot.Builder().setId(Long.parseLong(element.id().replace("screenshot-", ""))).setHtmlUrl(HOST + element.select("a.dribbble-link").first().attr("href")).setTitle(descriptionBlock.select("strong").first().text()).setDescription(description).setImages(new Images(null, imgUrl, null)).setCreatedAt(createdAt).setLikesCount(Long.parseLong(element.select("li.fav").first().child(0).text().replaceAll(",", ""))).setCommentsCount(Long.parseLong(element.select("li.cmnt").first().child(0).text().replaceAll(",", ""))).setViewsCount(Long.parseLong(element.select("li.views").first().child(0).text().replaceAll(",", ""))).setUser(parsePlayer(element.select("h2").first())).build();
}
Aggregations