use of org.mazhuang.guanggoo.data.entity.Meta in project guanggoo-android by mzlogin.
the class GetTopicListTask method createTopicFromElement.
public static Topic createTopicFromElement(Element element) {
Topic topic = new Topic();
Element titleElement = element.select("h3.title").select("a").first();
if (titleElement != null) {
// 主题列表页
topic.setTitle(titleElement.text());
} else {
// 主题详情页
titleElement = element.select("h3.title").first();
if (titleElement != null) {
topic.setTitle(titleElement.text());
}
}
topic.setUrl(titleElement.absUrl("href"));
topic.setAvatar(element.select("img.avatar").attr("src"));
Element metaElement = element.select("div.meta").first();
Meta meta = createMetaFromElement(metaElement);
topic.setMeta(meta);
Elements countElements = element.select("div.count");
if (!countElements.isEmpty()) {
topic.setCount(Integer.valueOf(countElements.first().select("a").first().text()));
}
return topic;
}
use of org.mazhuang.guanggoo.data.entity.Meta in project guanggoo-android by mzlogin.
the class GetTopicListTask method createMetaFromElement.
private static Meta createMetaFromElement(Element element) {
Meta meta = new Meta();
Element nodeElement = element.select("span.node").select("a").first();
Node node = new Node();
node.setTitle(nodeElement.text());
node.setUrl(nodeElement.absUrl("href"));
meta.setNode(node);
Element userElement = element.select("span.username").select("a").first();
User user = new User();
user.setUsername(userElement.text());
user.setUrl(userElement.absUrl("href"));
meta.setAuthor(user);
// 主题列表页
Elements lastTouchedElement = element.select("span.last-touched");
if (lastTouchedElement.isEmpty()) {
// 主题详情页
lastTouchedElement = element.select("span.last-reply-time");
}
meta.setLastTouched(lastTouchedElement.text());
Elements createdTimeElement = element.select("span.created-time");
meta.setCreatedTime(createdTimeElement.text());
Element lastReplyUserElement = element.select("span.last-reply-username").select("a").first();
if (lastReplyUserElement != null) {
User lastReplyUser = new User();
lastReplyUser.setUsername(lastReplyUserElement.select("strong").text());
lastReplyUser.setUrl(lastReplyUserElement.absUrl("href"));
meta.setLastReplyUser(lastReplyUser);
}
return meta;
}