use of com.hippo.ehviewer.client.data.GalleryCommentList in project EhViewer by seven332.
the class GalleryDetailParser method parseComments.
/**
* Parse comments with html parser
*/
@NonNull
public static GalleryCommentList parseComments(Document document) {
try {
Element cdiv = document.getElementById("cdiv");
Elements c1s = cdiv.getElementsByClass("c1");
List<GalleryComment> list = new ArrayList<>(c1s.size());
for (int i = 0, n = c1s.size(); i < n; i++) {
GalleryComment comment = parseComment(c1s.get(i));
if (null != comment) {
list.add(comment);
}
}
Element chd = cdiv.getElementById("chd");
MutableBoolean hasMore = new MutableBoolean(false);
NodeTraversor.traverse(new NodeVisitor() {
@Override
public void head(Node node, int depth) {
if (node instanceof Element && ((Element) node).text().equals("click to show all")) {
hasMore.value = true;
}
}
@Override
public void tail(Node node, int depth) {
}
}, chd);
return new GalleryCommentList(list.toArray(new GalleryComment[list.size()]), hasMore.value);
} catch (Throwable e) {
ExceptionUtils.throwIfFatal(e);
e.printStackTrace();
return EMPTY_GALLERY_COMMENT_ARRAY;
}
}
use of com.hippo.ehviewer.client.data.GalleryCommentList in project EhViewer by seven332.
the class GalleryDetailScene method onSceneResult.
@Override
protected void onSceneResult(int requestCode, int resultCode, Bundle data) {
switch(requestCode) {
case REQUEST_CODE_COMMENT_GALLERY:
if (resultCode != RESULT_OK || data == null) {
break;
}
GalleryCommentList comments = data.getParcelable(GalleryCommentsScene.KEY_COMMENT_LIST);
if (mGalleryDetail == null && comments == null) {
break;
}
mGalleryDetail.comments = comments;
bindComments(comments.comments);
break;
default:
super.onSceneResult(requestCode, resultCode, data);
}
}
Aggregations