use of com.instructure.pandarecycler.BaseExpandableRecyclerAdapter in project instructure-android by instructure.
the class ExpandableGridSpacingDecorator method getItemOffsets.
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
final BaseExpandableRecyclerAdapter adapter = (BaseExpandableRecyclerAdapter) parent.getAdapter();
final int position = parent.getChildAdapterPosition(view);
final boolean isHeader = adapter.isPositionGroupHeader(position);
final RecyclerView.ViewHolder viewHolder = parent.getChildViewHolder(view);
if (position == RecyclerView.NO_POSITION) {
// If this ItemDecoration does not affect the positioning of item views,
AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f);
anim.setDuration(175);
viewHolder.itemView.startAnimation(anim);
viewHolder.itemView.setVisibility(View.GONE);
return;
} else {
viewHolder.itemView.setVisibility(View.VISIBLE);
}
if (isHeader) {
return;
}
final int spanCount = getTotalSpan(parent);
// the visual position
final int pseudoGroupPosition = adapter.getGroupVisualPosition(position);
final int rows = ((adapter.getGroupItemCount(adapter.getGroup(pseudoGroupPosition)) - 1) / spanCount) + 1;
final int leftRightEdge = getIsEdgeType(spanCount, position, pseudoGroupPosition);
final int topBottomEdge = getIsTopBottomEdgeType(spanCount, rows, position, pseudoGroupPosition);
if (spanCount == 1) {
outRect.left = spacing;
outRect.right = spacing;
} else {
if (leftRightEdge == LEFT) {
outRect.left = spacing;
outRect.right = halfSpacing;
} else if (leftRightEdge == RIGHT) {
outRect.left = halfSpacing;
outRect.right = spacing;
} else {
outRect.left = halfSpacing;
outRect.right = halfSpacing;
}
}
if (rows == 1) {
outRect.top = spacing;
outRect.bottom = spacing;
} else {
if (topBottomEdge == TOP) {
outRect.top = spacing;
outRect.bottom = halfSpacing;
} else if (topBottomEdge == BOTTOM) {
outRect.top = halfSpacing;
outRect.bottom = spacing;
} else {
outRect.top = halfSpacing;
outRect.bottom = halfSpacing;
}
}
}
use of com.instructure.pandarecycler.BaseExpandableRecyclerAdapter in project instructure-android by instructure.
the class ExpandableGridSpacingDecorator method getItemOffsets.
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
final BaseExpandableRecyclerAdapter adapter = (BaseExpandableRecyclerAdapter) parent.getAdapter();
final int position = parent.getChildAdapterPosition(view);
final boolean isHeader = adapter.isPositionGroupHeader(position);
final RecyclerView.ViewHolder viewHolder = parent.getChildViewHolder(view);
if (position == RecyclerView.NO_POSITION) {
// If this ItemDecoration does not affect the positioning of item views,
AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f);
anim.setDuration(175);
viewHolder.itemView.startAnimation(anim);
viewHolder.itemView.setVisibility(View.GONE);
return;
} else {
viewHolder.itemView.setVisibility(View.VISIBLE);
}
if (isHeader) {
return;
}
final int spanCount = getTotalSpan(parent);
// the visual position
final int pseudoGroupPosition = adapter.getGroupVisualPosition(position);
final int rows = ((adapter.getGroupItemCount(adapter.getGroup(pseudoGroupPosition)) - 1) / spanCount) + 1;
final int leftRightEdge = getIsEdgeType(spanCount, position, pseudoGroupPosition);
final int topBottomEdge = getIsTopBottomEdgeType(spanCount, rows, position, pseudoGroupPosition);
if (spanCount == 1) {
outRect.left = spacing;
outRect.right = spacing;
} else {
if (leftRightEdge == LEFT) {
outRect.left = spacing;
outRect.right = halfSpacing;
} else if (leftRightEdge == RIGHT) {
outRect.left = halfSpacing;
outRect.right = spacing;
} else {
outRect.left = halfSpacing;
outRect.right = halfSpacing;
}
}
if (rows == 1) {
outRect.top = spacing;
outRect.bottom = spacing;
} else {
if (topBottomEdge == TOP) {
outRect.top = spacing;
outRect.bottom = halfSpacing;
} else if (topBottomEdge == BOTTOM) {
outRect.top = halfSpacing;
outRect.bottom = spacing;
} else {
outRect.top = halfSpacing;
outRect.bottom = halfSpacing;
}
}
}
Aggregations