当前位置: 首页>>代码示例>>Java>>正文


Java LayoutParams类代码示例

本文整理汇总了Java中org.telegram.messenger.support.widget.RecyclerView.LayoutParams的典型用法代码示例。如果您正苦于以下问题:Java LayoutParams类的具体用法?Java LayoutParams怎么用?Java LayoutParams使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LayoutParams类属于org.telegram.messenger.support.widget.RecyclerView包,在下文中一共展示了LayoutParams类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: nextViewFromScrapList

import org.telegram.messenger.support.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
/**
 * Returns the next item from the scrap list.
 * <p>
 * Upon finding a valid VH, sets current item position to VH.itemPosition + mItemDirection
 *
 * @return View if an item in the current position or direction exists if not null.
 */
private View nextViewFromScrapList() {
    final int size = mScrapList.size();
    for (int i = 0; i < size; i++) {
        final View view = mScrapList.get(i).itemView;
        final LayoutParams lp = (LayoutParams) view.getLayoutParams();
        if (lp.isItemRemoved()) {
            continue;
        }
        if (mCurrentPosition == lp.getViewLayoutPosition()) {
            assignPositionFromScrapList(view);
            return view;
        }
    }
    return null;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:23,代码来源:LinearLayoutManager.java

示例2: findReferenceChild

import org.telegram.messenger.support.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
View findReferenceChild(RecyclerView.Recycler recycler, RecyclerView.State state,
                        int start, int end, int itemCount) {
    ensureLayoutState();
    View invalidMatch = null;
    View outOfBoundsMatch = null;
    final int boundsStart = mOrientationHelper.getStartAfterPadding();
    final int boundsEnd = mOrientationHelper.getEndAfterPadding();
    final int diff = end > start ? 1 : -1;
    for (int i = start; i != end; i += diff) {
        final View view = getChildAt(i);
        final int position = getPosition(view);
        if (position >= 0 && position < itemCount) {
            if (((LayoutParams) view.getLayoutParams()).isItemRemoved()) {
                if (invalidMatch == null) {
                    invalidMatch = view; // removed item, least preferred
                }
            } else if (mOrientationHelper.getDecoratedStart(view) >= boundsEnd ||
                    mOrientationHelper.getDecoratedEnd(view) < boundsStart) {
                if (outOfBoundsMatch == null) {
                    outOfBoundsMatch = view; // item is not visible, less preferred
                }
            } else {
                return view;
            }
        }
    }
    return outOfBoundsMatch != null ? outOfBoundsMatch : invalidMatch;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:29,代码来源:LinearLayoutManager.java

示例3: assignPositionFromScrapList

import org.telegram.messenger.support.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
public void assignPositionFromScrapList(View ignore) {
    final View closest = nextViewInLimitedList(ignore);
    if (closest == null) {
        mCurrentPosition = NO_POSITION;
    } else {
        mCurrentPosition = ((LayoutParams) closest.getLayoutParams())
                .getViewLayoutPosition();
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:10,代码来源:LinearLayoutManager.java

示例4: nextViewInLimitedList

import org.telegram.messenger.support.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
public View nextViewInLimitedList(View ignore) {
    int size = mScrapList.size();
    View closest = null;
    int closestDistance = Integer.MAX_VALUE;
    if (DEBUG && mIsPreLayout) {
        throw new IllegalStateException("Scrap list cannot be used in pre layout");
    }
    for (int i = 0; i < size; i++) {
        View view = mScrapList.get(i).itemView;
        final LayoutParams lp = (LayoutParams) view.getLayoutParams();
        if (view == ignore || lp.isItemRemoved()) {
            continue;
        }
        final int distance = (lp.getViewLayoutPosition() - mCurrentPosition) *
                mItemDirection;
        if (distance < 0) {
            continue; // item is not in current direction
        }
        if (distance < closestDistance) {
            closest = view;
            closestDistance = distance;
            if (distance == 0) {
                break;
            }
        }
    }
    return closest;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:29,代码来源:LinearLayoutManager.java

示例5: layoutChunk

import org.telegram.messenger.support.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
void layoutChunk(RecyclerView.Recycler recycler, RecyclerView.State state,
        LayoutState layoutState, LayoutChunkResult result) {
    View view = layoutState.next(recycler);
    if (view == null) {
        if (DEBUG && layoutState.mScrapList == null) {
            throw new RuntimeException("received null view when unexpected");
        }
        // if we are laying out views in scrap, this may return null which means there is
        // no more items to layout.
        result.mFinished = true;
        return;
    }
    LayoutParams params = (LayoutParams) view.getLayoutParams();
    if (layoutState.mScrapList == null) {
        if (mShouldReverseLayout == (layoutState.mLayoutDirection
                == LayoutState.LAYOUT_START)) {
            addView(view);
        } else {
            addView(view, 0);
        }
    } else {
        if (mShouldReverseLayout == (layoutState.mLayoutDirection
                == LayoutState.LAYOUT_START)) {
            addDisappearingView(view);
        } else {
            addDisappearingView(view, 0);
        }
    }
    measureChildWithMargins(view, 0, 0);
    result.mConsumed = mOrientationHelper.getDecoratedMeasurement(view);
    int left, top, right, bottom;
    if (mOrientation == VERTICAL) {
        if (isLayoutRTL()) {
            right = getWidth() - getPaddingRight();
            left = right - mOrientationHelper.getDecoratedMeasurementInOther(view);
        } else {
            left = getPaddingLeft();
            right = left + mOrientationHelper.getDecoratedMeasurementInOther(view);
        }
        if (layoutState.mLayoutDirection == LayoutState.LAYOUT_START) {
            bottom = layoutState.mOffset;
            top = layoutState.mOffset - result.mConsumed;
        } else {
            top = layoutState.mOffset;
            bottom = layoutState.mOffset + result.mConsumed;
        }
    } else {
        top = getPaddingTop();
        bottom = top + mOrientationHelper.getDecoratedMeasurementInOther(view);

        if (layoutState.mLayoutDirection == LayoutState.LAYOUT_START) {
            right = layoutState.mOffset;
            left = layoutState.mOffset - result.mConsumed;
        } else {
            left = layoutState.mOffset;
            right = layoutState.mOffset + result.mConsumed;
        }
    }
    // We calculate everything with View's bounding box (which includes decor and margins)
    // To calculate correct layout position, we subtract margins.
    layoutDecorated(view, left + params.leftMargin, top + params.topMargin,
            right - params.rightMargin, bottom - params.bottomMargin);
    if (DEBUG) {
        Log.d(TAG, "laid out child at position " + getPosition(view) + ", with l:"
                + (left + params.leftMargin) + ", t:" + (top + params.topMargin) + ", r:"
                + (right - params.rightMargin) + ", b:" + (bottom - params.bottomMargin));
    }
    // Consume the available space if the view is not removed OR changed
    if (params.isItemRemoved() || params.isItemChanged()) {
        result.mIgnoreConsumed = true;
    }
    result.mFocusable = view.isFocusable();
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:74,代码来源:LinearLayoutManager.java

示例6: generateDefaultLayoutParams

import org.telegram.messenger.support.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public LayoutParams generateDefaultLayoutParams() {
    return new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:9,代码来源:LinearLayoutManager.java

示例7: isViewValidAsAnchor

import org.telegram.messenger.support.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
private boolean isViewValidAsAnchor(View child, RecyclerView.State state) {
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    return !lp.isItemRemoved() && lp.getViewLayoutPosition() >= 0
            && lp.getViewLayoutPosition() < state.getItemCount();
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:6,代码来源:LinearLayoutManager.java

示例8: layoutChunk

import org.telegram.messenger.support.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
void layoutChunk(RecyclerView.Recycler recycler, RecyclerView.State state,
        LayoutState layoutState, LayoutChunkResult result) {
    View view = layoutState.next(recycler);
    if (view == null) {
        if (DEBUG && layoutState.mScrapList == null) {
            throw new RuntimeException("received null view when unexpected");
        }
        // if we are laying out views in scrap, this may return null which means there is
        // no more items to layout.
        result.mFinished = true;
        return;
    }
    LayoutParams params = (LayoutParams) view.getLayoutParams();
    if (layoutState.mScrapList == null) {
        if (mShouldReverseLayout == (layoutState.mLayoutDirection
                == LayoutState.LAYOUT_START)) {
            addView(view);
        } else {
            addView(view, 0);
        }
    } else {
        if (mShouldReverseLayout == (layoutState.mLayoutDirection
                == LayoutState.LAYOUT_START)) {
            addDisappearingView(view);
        } else {
            addDisappearingView(view, 0);
        }
    }
    measureChildWithMargins(view, 0, 0);
    result.mConsumed = mOrientationHelper.getDecoratedMeasurement(view);
    int left, top, right, bottom;
    if (mOrientation == VERTICAL) {
        if (isLayoutRTL()) {
            right = getWidth() - getPaddingRight();
            left = right - mOrientationHelper.getDecoratedMeasurementInOther(view);
        } else {
            left = getPaddingLeft();
            right = left + mOrientationHelper.getDecoratedMeasurementInOther(view);
        }
        if (layoutState.mLayoutDirection == LayoutState.LAYOUT_START) {
            bottom = layoutState.mOffset;
            top = layoutState.mOffset - result.mConsumed;
        } else {
            top = layoutState.mOffset;
            bottom = layoutState.mOffset + result.mConsumed;
        }
    } else {
        top = getPaddingTop();
        bottom = top + mOrientationHelper.getDecoratedMeasurementInOther(view);

        if (layoutState.mLayoutDirection == LayoutState.LAYOUT_START) {
            right = layoutState.mOffset;
            left = layoutState.mOffset - result.mConsumed;
        } else {
            left = layoutState.mOffset;
            right = layoutState.mOffset + result.mConsumed;
        }
    }
    // We calculate everything with View's bounding box (which includes decor and margins)
    // To calculate correct layout position, we subtract margins.
    layoutDecoratedWithMargins(view, left, top, right, bottom);
    if (DEBUG) {
        Log.d(TAG, "laid out child at position " + getPosition(view) + ", with l:"
                + (left + params.leftMargin) + ", t:" + (top + params.topMargin) + ", r:"
                + (right - params.rightMargin) + ", b:" + (bottom - params.bottomMargin));
    }
    // Consume the available space if the view is not removed OR changed
    if (params.isItemRemoved() || params.isItemChanged()) {
        result.mIgnoreConsumed = true;
    }
    result.mFocusable = view.hasFocusable();
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:73,代码来源:LinearLayoutManager.java

示例9: isViewValidAsAnchor

import org.telegram.messenger.support.widget.RecyclerView.LayoutParams; //导入依赖的package包/类
boolean isViewValidAsAnchor(View child, RecyclerView.State state) {
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    return !lp.isItemRemoved() && lp.getViewLayoutPosition() >= 0
            && lp.getViewLayoutPosition() < state.getItemCount();
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:6,代码来源:LinearLayoutManager.java


注:本文中的org.telegram.messenger.support.widget.RecyclerView.LayoutParams类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。