use of androidx.recyclerview.widget.RecyclerView in project UltimateRecyclerView by cymcsg.
the class VerticalDividerItemDecoration method getDividerBound.
@Override
protected Rect getDividerBound(int position, RecyclerView parent, View child) {
Rect bounds = new Rect(0, 0, 0, 0);
int transitionX = (int) ViewCompat.getTranslationX(child);
int transitionY = (int) ViewCompat.getTranslationY(child);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
bounds.top = parent.getPaddingTop() + mMarginProvider.dividerTopMargin(position, parent) + transitionY;
bounds.bottom = parent.getHeight() - parent.getPaddingBottom() - mMarginProvider.dividerBottomMargin(position, parent) + transitionY;
int dividerSize = getDividerSize(position, parent);
if (mDividerType == DividerType.DRAWABLE) {
bounds.left = child.getRight() + params.leftMargin + transitionX;
bounds.right = bounds.left + dividerSize;
} else {
bounds.left = child.getRight() + params.leftMargin + dividerSize / 2 + transitionX;
bounds.right = bounds.left;
}
return bounds;
}
use of androidx.recyclerview.widget.RecyclerView in project UltimateRecyclerView by cymcsg.
the class HeaderPositionCalculator method itemIsObscuredByHeader.
/**
* Determines if an item is obscured by a header
*
* @param parent
* @param item to determine if obscured by header
* @param header that might be obscuring the item
* @param orientation of the {@link RecyclerView}
* @return true if the item view is obscured by the header view
*/
private boolean itemIsObscuredByHeader(RecyclerView parent, View item, View header, int orientation) {
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) item.getLayoutParams();
Rect headerMargins = mDimensionCalculator.getMargins(header);
int adapterPosition = parent.getChildAdapterPosition(item);
if (adapterPosition == RecyclerView.NO_POSITION || mHeaderProvider.getHeader(parent, adapterPosition) != header) {
// Handles an edge case where a trailing header is smaller than the current sticky header.
return false;
}
if (orientation == LinearLayoutManager.VERTICAL) {
int itemTop = item.getTop() - layoutParams.topMargin;
int headerBottom = header.getBottom() + headerMargins.bottom + headerMargins.top;
if (itemTop > headerBottom) {
return false;
}
} else {
int itemLeft = item.getLeft() - layoutParams.leftMargin;
int headerRight = header.getRight() + headerMargins.right + headerMargins.left;
if (itemLeft > headerRight) {
return false;
}
}
return true;
}
use of androidx.recyclerview.widget.RecyclerView in project UltimateRecyclerView by cymcsg.
the class HeaderPositionCalculator method getHeaderBounds.
public Rect getHeaderBounds(RecyclerView recyclerView, View header, View firstView, boolean firstHeader) {
int orientation = mOrientationProvider.getOrientation(recyclerView);
Rect bounds = getDefaultHeaderOffset(recyclerView, header, firstView, orientation);
if (firstHeader && isStickyHeaderBeingPushedOffscreen(recyclerView, header)) {
View viewAfterNextHeader = getFirstViewUnobscuredByHeader(recyclerView, header);
int firstViewUnderHeaderPosition = recyclerView.getChildAdapterPosition(viewAfterNextHeader);
View secondHeader = mHeaderProvider.getHeader(recyclerView, firstViewUnderHeaderPosition);
translateHeaderWithNextHeader(recyclerView, mOrientationProvider.getOrientation(recyclerView), bounds, header, viewAfterNextHeader, secondHeader);
}
return bounds;
}
use of androidx.recyclerview.widget.RecyclerView in project UltimateRecyclerView by cymcsg.
the class StickyRecyclerHeadersDecoration method getItemOffsets.
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
int itemPosition = parent.getChildAdapterPosition(view);
if (itemPosition == RecyclerView.NO_POSITION) {
return;
}
if (mHeaderPositionCalculator.hasNewHeader(itemPosition)) {
View header = getHeaderView(parent, itemPosition);
setItemOffsetsForHeader(outRect, header, mOrientationProvider.getOrientation(parent));
}
}
use of androidx.recyclerview.widget.RecyclerView in project UltimateRecyclerView by cymcsg.
the class SimpleItemTouchHelperCallback method onChildDraw.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
// Fade out the view as it is swiped out of the parent's bounds
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
View itemView = viewHolder.itemView;
final float alpha = ALPHA_FULL - Math.abs(dX) / (float) itemView.getWidth();
itemView.setAlpha(alpha);
}
}
Aggregations