當前位置: 首頁>>代碼示例>>Java>>正文


Java RecyclerView.State方法代碼示例

本文整理匯總了Java中android.support.v7.widget.RecyclerView.State方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.State方法的具體用法?Java RecyclerView.State怎麽用?Java RecyclerView.State使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.RecyclerView的用法示例。


在下文中一共展示了RecyclerView.State方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onDraw

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
  boolean isReverseLayout = getIsReverseLayout(parent);
  int childCount = parent.getChildCount();
  for (int i = 0; i < childCount; i++) {
    View child = parent.getChildAt(i);
    int adapterPosition = parent.getChildAdapterPosition(child);
    if (adapterPosition < 0) {
      return;
    }
    ItemBinder binder = adapter.getBinderForPosition(adapterPosition);
    if (binder.isItemDecorationEnabled()) {
      int itemPosition = adapter.getItemPositionInManager(parent.getChildAdapterPosition(child));
      int positionType = getPositionType(parent, adapterPosition, itemPosition, isReverseLayout);
      binder.onDraw(canvas, parent, child, itemPosition, positionType);
    }
  }
}
 
開發者ID:DevAhamed,項目名稱:MultiViewAdapter,代碼行數:18,代碼來源:ItemDecorationManager.java

示例2: computeScrollRange

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private int computeScrollRange(RecyclerView.State state) {
    if (lm.getChildCount() == 0 || state.getItemCount() == 0) {
        return 0;
    }

    if (!lm.isSmoothScrollbarEnabled()) {
        return state.getItemCount();
    }

    int firstVisiblePos = lm.findFirstVisibleItemPosition();
    int lastVisiblePos = lm.findLastVisibleItemPosition();

    // smooth scrollbar enabled. try to estimate better.
    final int laidOutRange = Math.abs(firstVisiblePos - lastVisiblePos) + 1;

    // estimate a size for full list.
    return (int) ((float) getLaidOutArea() / laidOutRange * state.getItemCount());
}
 
開發者ID:sathishmscict,項目名稱:ChipsLayoutManager,代碼行數:19,代碼來源:ScrollingController.java

示例3: getItemOffsets

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView recyclerView, RecyclerView.State state) {
    final RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
    final Context context = recyclerView.getContext();

    if(!registered) {
        MaterialViewPagerHelper.registerRecyclerView(context, recyclerView);
        registered = true;
    }

    int headerCells = 1;

    //don't work with stagged
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if(layoutManager instanceof GridLayoutManager){
        GridLayoutManager gridLayoutManager = (GridLayoutManager)layoutManager;
        headerCells = gridLayoutManager.getSpanCount();
    }

    MaterialViewPagerAnimator animator = MaterialViewPagerHelper.getAnimator(context);
    if (animator != null) {
        if (holder.getAdapterPosition() < headerCells) {
            outRect.top = Math.round(Utils.dpToPx(animator.getHeaderHeight() + 10, context));
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:MaterialViewPagerHeaderDecorator.java

示例4: getItemOffsets

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

    int layoutOrientation = getOrientation(parent);
    if (layoutOrientation == LinearLayoutManager.VERTICAL) {
        outRect.top = 10;
        outRect.left=5;
        outRect.right=5;
    } else if(layoutOrientation == LinearLayoutManager.HORIZONTAL) {
        outRect.left = 5;
    }
}
 
開發者ID:yiwent,項目名稱:Mobike,代碼行數:13,代碼來源:CardViewtemDecortion.java

示例5: onDraw

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    super.onDraw(c, parent, state);
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        int position = parent.getChildLayoutPosition(child);
        int column = (position + 1) % 3;
        column  = column == 0 ? mSpanCount : column;

        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin +
                Math.round(ViewCompat.getTranslationY(child));
        final int bottom = top + mDivider.getIntrinsicHeight();
        final int left = child.getRight() + params.rightMargin +
                Math.round(ViewCompat.getTranslationX(child));
        final int right = left + mDivider.getIntrinsicHeight();

        mDivider.setBounds(child.getLeft(), top, right, bottom);
        mDivider.draw(c);

        if(column < mSpanCount) {
            mDivider.setBounds(left, child.getTop(), right, bottom);
            mDivider.draw(c);
        }

    }
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:30,代碼來源:GridDividerItemDecoration.java

示例6: assignSpans

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void assignSpans(GridRangeStyle rangeStyle, RecyclerView.Recycler recycler, RecyclerView.State state, int count,
    int consumedSpanCount, boolean layingOutInPrimaryDirection, LayoutManagerHelper helper) {
    int span, spanDiff, start, end, diff;
    // make sure we traverse from min position to max position
    if (layingOutInPrimaryDirection) {
        start = 0;
        end = count;
        diff = 1;
    } else {
        start = count - 1;
        end = -1;
        diff = -1;
    }

    if (helper.getOrientation() == VERTICAL && helper.isDoLayoutRTL()) { // start from last span
        span = consumedSpanCount - 1;
        spanDiff = -1;
    } else {
        span = 0;
        spanDiff = 1;
    }

    for (int i = start; i != end; i += diff) {
        View view = rangeStyle.mSet[i];
        int spanSize = getSpanSize(rangeStyle.mSpanSizeLookup, recycler, state, helper.getPosition(view));
        if (spanDiff == -1 && spanSize > 1) {
            rangeStyle.mSpanIndices[i] = span - (spanSize - 1);
        } else {
            rangeStyle.mSpanIndices[i] = span;
        }
        span += spanDiff * spanSize;
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:34,代碼來源:RangeGridLayoutHelper.java

示例7: fill

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * 填充方法
 *
 * @param recycler
 * @param state
 */
private void fill(RecyclerView.Recycler recycler, RecyclerView.State state) {
    if (getItemCount() <= 0 || state.isPreLayout()) {
        return;
    }
    //考慮到當前RecyclerView會處於滑動的狀態,所以這裏的Rect的作用是展示當前顯示的區域
    //需要考慮到RecyclerView的滑動量
    //mHorizontalOffset 橫向的滑動偏移量
    //mVerticalOffset  縱向的滑動偏移量
    Rect displayRect = new Rect(0, mVerticalOffset,
            getHorizontalSpace(),
            getVerticalSpace() + mVerticalOffset);

    /**
     * 對這些View進行測量和布局操作
     */
    for (int i = 0; i < getItemCount(); i++) {
        Rect frame = mItemFrames.get(i);
        if (Rect.intersects(displayRect, frame)) {
            View scrap = recycler.getViewForPosition(i);
            addView(scrap);
            //測量子View
            measureChildWithMargins(scrap, 0, 0);
            //布局方法
            layoutDecorated(scrap, frame.left - mHorizontalOffset, frame.top - mVerticalOffset,
                    frame.right - mHorizontalOffset, frame.bottom - mVerticalOffset);
        }
    }
}
 
開發者ID:Vander-liu,項目名稱:HexagonRecyclerView,代碼行數:35,代碼來源:PolygonLayoutManager.java

示例8: onDraw

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
   if (mOrientation == OrientationHelper.HORIZONTAL){
       drawHorizontal(c,parent);
   }else {
       drawVertical(c,parent); 
   }
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:9,代碼來源:UIDivider.java

示例9: getItemOffsets

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
                           RecyclerView.State state) {
    if (mOrientation == VERTICAL) {
        outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
    } else {
        outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
    }
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:10,代碼來源:CustomDividerItemDecoration.java

示例10: getItemOffsets

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    if (mOrientation == VERTICAL_LIST) {
        outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
    } else {
        outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
    }
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:9,代碼來源:DividerItemDecoration.java

示例11: getItemOffsets

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
  if (mOrientation == VERTICAL_LIST) {
    outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
  } else {
    outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
  }
}
 
開發者ID:tomoya92,項目名稱:android-apps,代碼行數:9,代碼來源:MyRecylerViewAdapter.java

示例12: smoothScrollToPosition

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state,
                                   int position) {
    View firstVisibleChild = recyclerView.getChildAt(0);
    int itemHeight = firstVisibleChild.getHeight();
    int currentPosition = recyclerView.getChildLayoutPosition(firstVisibleChild);
    int distanceInPixels = Math.abs((currentPosition - position) * itemHeight);
    if (distanceInPixels == 0) {
        distanceInPixels = (int) Math.abs(firstVisibleChild.getY());
    }
    SmoothScroller smoothScroller = new SmoothScroller(recyclerView.getContext(), distanceInPixels, duration);
    smoothScroller.setTargetPosition(position);
    startSmoothScroll(smoothScroller);
}
 
開發者ID:hypeapps,項目名稱:black-mirror,代碼行數:15,代碼來源:ScrollingLinearLayoutManager.java

示例13: onLayoutCompleted

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void onLayoutCompleted(RecyclerView.State state) {
    super.onLayoutCompleted(state);
    mPendingScrollPosition = -1;
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:6,代碼來源:ScrollPosLinearLayoutManager.java

示例14: getItemOffsets

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
    outRect.set(0, 0, 0, dividerHeight);
}
 
開發者ID:zongkaili,項目名稱:MenuSet,代碼行數:5,代碼來源:DividerItemDecoration.java

示例15: layoutDisappearingViews

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void layoutDisappearingViews(
        RecyclerView.Recycler recycler, RecyclerView.State state, int startTop) {
    // TODO
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:5,代碼來源:SpannedGridLayoutManager.java


注:本文中的android.support.v7.widget.RecyclerView.State方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。