use of org.mazhuang.guanggoo.data.entity.User 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;
}
use of org.mazhuang.guanggoo.data.entity.User in project guanggoo-android by mzlogin.
the class GetCommentsTask method getCommentFromElement.
public static Comment getCommentFromElement(Element element) {
Comment comment = new Comment();
comment.setAvatar(element.select("img.avatar").attr("src"));
Element metaElement = element.select("div.meta").first();
Comment.Meta meta = new Comment.Meta();
Element replyUsernameElement = metaElement.select("a.reply-username").first();
User replier = new User();
replier.setUrl(replyUsernameElement.absUrl("href"));
replier.setUsername(replyUsernameElement.select("span.username").text());
meta.setReplier(replier);
meta.setTime(metaElement.select("span.time").text());
try {
meta.setFloor(Integer.valueOf(metaElement.select("span.fr.floor").first().text().replaceAll("[^\\d]", "")));
} catch (NumberFormatException e) {
e.printStackTrace();
meta.setFloor(0);
}
Element voteElement = metaElement.select("a.J_replyVote").first();
Comment.Vote vote = new Comment.Vote();
vote.setUrl(voteElement.absUrl("href"));
try {
vote.setCount(Integer.valueOf(voteElement.attr("data-count")));
} catch (NumberFormatException e) {
e.printStackTrace();
vote.setCount(0);
}
meta.setVote(vote);
comment.setMeta(meta);
comment.setContent(element.select("span.content").outerHtml());
return comment;
}