Search in sources :

Example 1 with CommentListView

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);
            }
        }
    }
}
Also used : CommentListView(com.yiw.circledemo.widgets.CommentListView) CommentListView(com.yiw.circledemo.widgets.CommentListView) ImageView(android.widget.ImageView) View(android.view.View) SuperRecyclerView(com.malinskiy.superrecyclerview.SuperRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 SuperRecyclerView (com.malinskiy.superrecyclerview.SuperRecyclerView)1 CommentListView (com.yiw.circledemo.widgets.CommentListView)1