Java Code Examples for com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter#isHeader()
The following examples show how to use
com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter#isHeader() .
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: GridItemDecoration.java From LRecyclerView with Apache License 2.0 | 6 votes |
public void drawHorizontal(Canvas c, RecyclerView parent) { int childCount = parent.getChildCount(); LRecyclerView recyclerView = (LRecyclerView) parent; LRecyclerViewAdapter adapter = (LRecyclerViewAdapter) parent.getAdapter(); for (int i = 0; i < childCount; i++) { if ((recyclerView.isOnTop() && (adapter.isHeader(i) || adapter.isRefreshHeader(i))) || adapter.isFooter(i)) { c.drawRect(0, 0, 0, 0, mPaint); } else { final View child = parent.getChildAt(i); final int top = child.getBottom(); final int bottom = top + verticalSpace; int left = child.getLeft(); int right = child.getRight(); c.drawRect(left, top, right, bottom, mPaint); } } }
Example 2
Source File: GridItemDecoration.java From LRecyclerView with Apache License 2.0 | 6 votes |
public void drawVertical(Canvas c, RecyclerView parent) { final int childCount = parent.getChildCount(); LRecyclerView recyclerView = (LRecyclerView) parent; LRecyclerViewAdapter adapter = (LRecyclerViewAdapter) parent.getAdapter(); for (int i = 0; i < childCount; i++) { if ((recyclerView.isOnTop() && (adapter.isHeader(i) || adapter.isRefreshHeader(i))) || adapter.isFooter(i)) { c.drawRect(0, 0, 0, 0, mPaint); } else { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int top = child.getTop(); final int bottom = child.getBottom() + verticalSpace; final int left = child.getRight() + params.rightMargin; final int right = left + horizontalSpace; c.drawRect(left, top, right, bottom, mPaint); } } }
Example 3
Source File: SpacesItemDecoration.java From LRecyclerView with Apache License 2.0 | 6 votes |
public void drawHorizontal(Canvas c, RecyclerView parent,LRecyclerViewAdapter adapter) { int count = parent.getChildCount(); for (int i = 0; i < count; i++) { final View child = parent.getChildAt(i); final int top = child.getBottom(); final int bottom = top + verticalSpacing; int left = child.getLeft() ; int right = child.getRight(); int position = parent.getChildAdapterPosition(child); c.save(); if (adapter.isRefreshHeader(position) || adapter. isHeader(position) || adapter.isFooter(position)) { c.drawRect(0, 0, 0, 0, mPaint); }else { c.drawRect(left, top, right, bottom, mPaint); } c.restore(); } }
Example 4
Source File: SpacesItemDecoration.java From LRecyclerView with Apache License 2.0 | 6 votes |
public void drawVertical(Canvas c, RecyclerView parent,LRecyclerViewAdapter adapter) { int count = parent.getChildCount(); for (int i = 0; i < count; i++) { final View child = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); final int top = child.getTop(); //final int bottom = child.getBottom() + params.bottomMargin; final int bottom = child.getBottom() + verticalSpacing; //这里使用verticalSpacing 代替 params.bottomMargin final int left = child.getRight() + params.rightMargin; final int right = left + itemSplitMarginEven*2; int position = parent.getChildAdapterPosition(child); c.save(); if (adapter.isRefreshHeader(position) || adapter. isHeader(position) || adapter.isFooter(position)) { c.drawRect(0, 0, 0, 0, mPaint); }else { c.drawRect(left, top, right, bottom, mPaint); } c.restore(); } }
Example 5
Source File: SpacesItemDecoration.java From LRecyclerView with Apache License 2.0 | 5 votes |
private static int getItemTopSpacing(SpanLookup spanLookup, int verticalSpacing, int itemPosition, int spanCount, int childCount, LRecyclerViewAdapter adapter) { if(adapter.isHeader(itemPosition) || adapter.isRefreshHeader(itemPosition) || adapter.isFooter(itemPosition)) { return 0; } else { if (itemIsOnTheTopRow(spanLookup, itemPosition, spanCount, childCount)) { return 0; } else { return (int) (.5f * verticalSpacing); } } }
Example 6
Source File: SpacesItemDecoration.java From LRecyclerView with Apache License 2.0 | 5 votes |
private static int getItemBottomSpacing(SpanLookup spanLookup, int verticalSpacing, int itemPosition, int childCount, LRecyclerViewAdapter adapter) { if(adapter.isHeader(itemPosition) || adapter.isRefreshHeader(itemPosition) || adapter.isFooter(itemPosition)) { return 0; } else { if (itemIsOnTheBottomRow(spanLookup, itemPosition, childCount)) { return 0; } else { return (int) (.5f * verticalSpacing); } } }
Example 7
Source File: GridItemDecoration.java From LRecyclerView with Apache License 2.0 | 4 votes |
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, State state) { super.getItemOffsets(outRect, view, parent, state); int itemPosition = parent.getChildAdapterPosition(view); int spanCount = getSpanCount(parent); int childCount = parent.getAdapter().getItemCount(); LRecyclerViewAdapter adapter = (LRecyclerViewAdapter) parent.getAdapter(); if (adapter.isFooter(itemPosition) || adapter.isHeader(itemPosition) || adapter.isRefreshHeader(itemPosition)) { //header,footer不进行绘制 outRect.set(0, 0, 0, 0); } else { if (!(parent.getLayoutManager() instanceof GridLayoutManager)) { //LinearLayoutManager if (itemPosition == (childCount - 2 - adapter.getHeaderViews().size())) outRect.set(0, 0, 0, 0); else outRect.set(0, 0, 0, verticalSpace); } else { //GridLayoutManager if (isLastRaw(parent, itemPosition, spanCount, childCount - 2 - adapter.getHeaderViews().size())) { //最后一行 if (isLastColumn(parent, itemPosition, spanCount)) { // 最后一行最后一列 outRect.set(0, 0, 0, verticalSpace); } else { // 最后一行不是最后一列 outRect.set(0, 0, horizontalSpace, verticalSpace); } } else { //最后一列 if (isLastColumn(parent, itemPosition, spanCount)) { // 最后一列最后一行 outRect.set(0, 0, 0, verticalSpace); } else { // 最后一列非最后一行 outRect.set(0, 0, horizontalSpace, verticalSpace); } } } } }