Java Code Examples for android.support.v7.widget.RecyclerView.LayoutParams#getViewLayoutPosition()

The following examples show how to use android.support.v7.widget.RecyclerView.LayoutParams#getViewLayoutPosition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinearLayoutManager.java    From letv with Apache License 2.0 6 votes vote down vote up
public View nextViewInLimitedList(View ignore) {
    int size = this.mScrapList.size();
    View closest = null;
    int closestDistance = Integer.MAX_VALUE;
    for (int i = 0; i < size; i++) {
        View view = ((ViewHolder) this.mScrapList.get(i)).itemView;
        LayoutParams lp = (LayoutParams) view.getLayoutParams();
        if (!(view == ignore || lp.isItemRemoved())) {
            int distance = (lp.getViewLayoutPosition() - this.mCurrentPosition) * this.mItemDirection;
            if (distance >= 0 && distance < closestDistance) {
                closest = view;
                closestDistance = distance;
                if (distance == 0) {
                    break;
                }
            }
        }
    }
    return closest;
}
 
Example 2
Source File: LinearLayoutManager.java    From Mupdf with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: LinearLayoutManager.java    From letv with Apache License 2.0 5 votes vote down vote up
private View nextViewFromScrapList() {
    int size = this.mScrapList.size();
    for (int i = 0; i < size; i++) {
        View view = ((ViewHolder) this.mScrapList.get(i)).itemView;
        LayoutParams lp = (LayoutParams) view.getLayoutParams();
        if (!lp.isItemRemoved() && this.mCurrentPosition == lp.getViewLayoutPosition()) {
            assignPositionFromScrapList(view);
            return view;
        }
    }
    return null;
}
 
Example 4
Source File: LinearLayoutManager.java    From Mupdf with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: LinearLayoutManager.java    From letv with Apache License 2.0 4 votes vote down vote up
private boolean isViewValidAsAnchor(View child, State state) {
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    return !lp.isItemRemoved() && lp.getViewLayoutPosition() >= 0 && lp.getViewLayoutPosition() < state.getItemCount();
}
 
Example 6
Source File: LinearLayoutManager.java    From Mupdf with Apache License 2.0 4 votes vote down vote up
private boolean isViewValidAsAnchor(View child, RecyclerView.State state) {
    LayoutParams lp = (LayoutParams) child.getLayoutParams();
    return !lp.isItemRemoved() && lp.getViewLayoutPosition() >= 0
            && lp.getViewLayoutPosition() < state.getItemCount();
}