use of com.dante.data.model.VideoComment in project 91Pop by DanteAndroid.
the class Parse91PronVideo method parseVideoComment.
/**
* 解析视频评论
*
* @param html 评论html
* @return 评论列表
*/
public static List<VideoComment> parseVideoComment(String html) {
List<VideoComment> videoCommentList = new ArrayList<>();
Document doc = Jsoup.parse(html);
Elements elements = doc.select("table.comment-divider");
for (Element element : elements) {
VideoComment videoComment = new VideoComment();
String ownnerUrl = element.select("a[href*=UID]").first().attr("href");
String uid = ownnerUrl.substring(ownnerUrl.indexOf("=") + 1, ownnerUrl.length());
videoComment.setUid(uid);
// Logger.t(TAG).d(uid);
String uName = element.select("a[href*=UID]").first().text();
videoComment.setuName(uName);
Logger.t(TAG).d(uName);
String replyTime = element.select("span.comment-info").first().text();
videoComment.setReplyTime(replyTime.replace("(", "").replace(")", ""));
// Logger.t(TAG).d(replyTime);
String tmpreplyId = element.select("div.comment-body").first().attr("id");
String replyId = tmpreplyId.substring(tmpreplyId.lastIndexOf("_") + 1, tmpreplyId.length());
videoComment.setReplyId(replyId);
// Logger.t(TAG).d("replyId:" + replyId);
String comment = element.select("div.comment-body").first().text().replace("举报", "").replace("Show", "");
// videoComment.setContentMessage(comment.replace("Show", ""));
// Logger.t(TAG).d(comment);
List<String> tmpQuoteList = new ArrayList<>();
tmpQuoteList.add(comment);
Elements quotes = element.select("div.comment-body").select("div.comment_quote");
for (Element element1 : quotes) {
String quote = element1.text();
tmpQuoteList.add(quote);
}
List<String> quoteList = new ArrayList<>();
for (int i = 0; i < tmpQuoteList.size(); i++) {
String quote;
if (i + 1 >= tmpQuoteList.size()) {
quote = tmpQuoteList.get(i);
quoteList.add(0, quote.trim());
// Logger.t(TAG).d(quote);
break;
}
quote = tmpQuoteList.get(i).replace(tmpQuoteList.get(i + 1), "");
quoteList.add(0, quote.trim());
// Logger.t(TAG).d(quote);
}
videoComment.setCommentQuoteList(quoteList);
String info = element.select("td").first().text();
String titleInfo = info.substring(0, info.indexOf("("));
videoComment.setTitleInfo(titleInfo.replace(uName, ""));
// Logger.t(TAG).d(titleInfo);
videoCommentList.add(videoComment);
}
return videoCommentList;
}
use of com.dante.data.model.VideoComment in project 91Pop by DanteAndroid.
the class PlayVideoPresenter method loadVideoComment.
@Override
public void loadVideoComment(String videoId, String viewKey, final boolean pullToRefresh) {
if (pullToRefresh) {
start = 1;
}
dataManager.loadPorn91VideoComments(videoId, start, viewKey).retryWhen(new RetryWhenProcess(RetryWhenProcess.PROCESS_TIME)).compose(RxSchedulersHelper.<List<VideoComment>>ioMainThread()).compose(provider.<List<VideoComment>>bindUntilEvent(Lifecycle.Event.ON_STOP)).map(new Function<List<VideoComment>, List<VideoComment>>() {
@Override
public List<VideoComment> apply(List<VideoComment> videoComments) throws Exception {
List<VideoComment> newList = new ArrayList<>();
for (VideoComment c : videoComments) {
List<String> list = c.getCommentQuoteList();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
builder.append(list.get(i));
}
if (invalidComment(builder.toString())) {
Logger.d("invalidComment " + builder.toString());
} else {
newList.add(c);
}
}
return newList;
}
}).subscribe(new CallBackWrapper<List<VideoComment>>() {
@Override
public void onBegin(Disposable d) {
ifViewAttached(new ViewAction<PlayVideoView>() {
@Override
public void run(@NonNull PlayVideoView view) {
if (start == 1 && pullToRefresh) {
view.showLoading(pullToRefresh);
}
}
});
}
@Override
public void onSuccess(final List<VideoComment> videoCommentList) {
ifViewAttached(new ViewAction<PlayVideoView>() {
@Override
public void run(@NonNull PlayVideoView view) {
if (start == 1) {
view.setVideoCommentData(videoCommentList, pullToRefresh);
} else {
view.setMoreVideoCommentData(videoCommentList);
}
if (videoCommentList.size() == 0 && start == 1) {
view.noMoreVideoCommentData("暂无评论");
} else if (videoCommentList.size() == 0 && start > 1) {
view.noMoreVideoCommentData("没有更多评论了");
}
start++;
view.showContent();
}
});
}
@Override
public void onError(final String msg, int code) {
ifViewAttached(new ViewAction<PlayVideoView>() {
@Override
public void run(@NonNull PlayVideoView view) {
if (start == 1) {
view.loadVideoCommentError(msg);
} else {
view.loadMoreVideoCommentError(msg);
}
}
});
}
@Override
public void onCancel(boolean isCancel) {
ifViewAttached(new ViewAction<PlayVideoView>() {
@Override
public void run(@NonNull PlayVideoView view) {
Logger.t(TAG).d("------getVideoComments onCancel----------------------------");
if (start == 1) {
view.loadVideoCommentError("取消请求");
} else {
view.loadMoreVideoCommentError("取消请求");
}
}
});
}
});
}
use of com.dante.data.model.VideoComment in project 91Pop by DanteAndroid.
the class BasePlayVideo method initVideoComments.
private void initVideoComments() {
List<VideoComment> videoCommentList = new ArrayList<>();
videoCommentAdapter = new VideoCommentAdapter(this, R.layout.item_video_comment, videoCommentList);
recyclerViewVideoComment.setLayoutManager(new LinearLayoutManager(this));
// recyclerViewVideoComment.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
recyclerViewVideoComment.setAdapter(videoCommentAdapter);
videoCommentAdapter.setLoadMoreView(new LoadMoreView() {
@Override
public int getLayoutId() {
return R.layout.loading;
}
@Override
protected int getLoadingViewId() {
return R.id.loading;
}
@Override
protected int getLoadFailViewId() {
return R.id.loadFailed;
}
@Override
protected int getLoadEndViewId() {
return R.id.loadEnd;
}
});
videoCommentAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override
public void onLoadMoreRequested() {
// 加载评论
if (unLimit91PornItem.getVideoResultId() == 0) {
videoCommentAdapter.loadMoreFail();
return;
}
presenter.loadVideoComment(unLimit91PornItem.getVideoResult().getVideoId(), unLimit91PornItem.getViewKey(), false);
}
}, recyclerViewVideoComment);
videoCommentAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
if (floatingToolbar.isShowing()) {
floatingToolbar.hide();
}
if (commentLayoutShown) {
if (videoCommentAdapter.getClickPosition() == position) {
hideCommentLayout();
}
} else {
showCommentLayout();
}
isComment = false;
videoComment = (VideoComment) adapter.getData().get(position);
etVideoComment.setHint("回复:" + videoComment.getuName());
videoCommentAdapter.setClickPosition(position);
}
});
recyclerViewVideoComment.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy > 0)
fab.hide();
else if (dy < -5)
fab.show();
}
});
}
Aggregations