Search in sources :

Example 1 with CommentListView

use of com.litingzhe.justandroid.ui.listandGridView.wechatCircle.widgets.CommentListView in project JustAndroid by chinaltz.

the class WeChatCircleActivity 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.litingzhe.justandroid.ui.listandGridView.wechatCircle.widgets.CommentListView) CommentListView(com.litingzhe.justandroid.ui.listandGridView.wechatCircle.widgets.CommentListView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 CommentListView (com.litingzhe.justandroid.ui.listandGridView.wechatCircle.widgets.CommentListView)1