use of com.yiw.circledemo.widgets.CommentListView in project CircleDemo by Naoki2015.
the class MainActivity method measureCircleItemHighAndCommentItemOffset.
private void measureCircleItemHighAndCommentItemOffset(CommentConfig commentConfig) {
if (commentConfig == null)
return;
int firstPosition = layoutManager.findFirstVisibleItemPosition();
//只能返回当前可见区域(列表可滚动)的子项
View selectCircleItem = layoutManager.getChildAt(commentConfig.circlePosition + CircleAdapter.HEADVIEW_SIZE - firstPosition);
if (selectCircleItem != null) {
selectCircleItemH = selectCircleItem.getHeight();
}
if (commentConfig.commentType == CommentConfig.Type.REPLY) {
//回复评论的情况
CommentListView commentLv = (CommentListView) selectCircleItem.findViewById(R.id.commentList);
if (commentLv != null) {
//找到要回复的评论view,计算出该view距离所属动态底部的距离
View selectCommentItem = commentLv.getChildAt(commentConfig.commentPosition);
if (selectCommentItem != null) {
//选择的commentItem距选择的CircleItem底部的距离
selectCommentItemOffset = 0;
View parentView = selectCommentItem;
do {
int subItemBottom = parentView.getBottom();
parentView = (View) parentView.getParent();
if (parentView != null) {
selectCommentItemOffset += (parentView.getHeight() - subItemBottom);
}
} while (parentView != null && parentView != selectCircleItem);
}
}
}
}
Aggregations