use of android.support.v7.app.ActionBar.LayoutParams in project SuperSLiM by TonicArtos.
the class LayoutManager method trimStart.
/**
* Trim content wholly beyond the start edge.
*
* @param state Layout state.
*/
private void trimStart(LayoutState state) {
// Find the first view visible on the screen.
View anchor = null;
int anchorIndex = 0;
for (int i = 0; i < getChildCount(); i++) {
View look = getChildAt(i);
if (getDecoratedBottom(look) > 0) {
anchor = look;
anchorIndex = i;
break;
}
}
if (anchor == null) {
detachAndScrapAttachedViews(state.recycler);
return;
}
LayoutParams anchorParams = (LayoutParams) anchor.getLayoutParams();
if (anchorParams.isHeader) {
for (int i = anchorIndex - 1; i >= 0; i--) {
View look = getChildAt(i);
LayoutParams lookParams = (LayoutParams) look.getLayoutParams();
if (lookParams.getTestedFirstPosition() == anchorParams.getTestedFirstPosition()) {
anchor = look;
anchorParams = lookParams;
anchorIndex = i;
break;
}
}
}
for (int i = 0; i < anchorIndex; i++) {
removeAndRecycleViewAt(0, state.recycler);
}
int sfp = anchorParams.getTestedFirstPosition();
View header = findAttachedHeaderForSection(sfp, Direction.START);
if (header != null) {
if (getDecoratedTop(header) < 0) {
updateHeaderForTrimFromStart(header);
}
if (getDecoratedBottom(header) <= 0) {
removeAndRecycleView(header, state.recycler);
}
}
}
use of android.support.v7.app.ActionBar.LayoutParams in project SuperSLiM by TonicArtos.
the class LayoutManager method getAnchorChild.
/**
* Find the first view in the hierarchy that can act as an anchor.
*
* @return The anchor view, or null if no view is a valid anchor.
*/
private View getAnchorChild() {
if (getChildCount() == 0) {
return null;
}
final View child = getChildAt(0);
final LayoutParams params = (LayoutParams) child.getLayoutParams();
final int sfp = params.getTestedFirstPosition();
final View first = findAttachedHeaderOrFirstViewForSection(sfp, 0, Direction.START);
if (first == null) {
return child;
}
final LayoutParams firstParams = (LayoutParams) first.getLayoutParams();
if (!firstParams.isHeader) {
return child;
}
if (firstParams.isHeaderInline() && !firstParams.isHeaderOverlay()) {
if (getDecoratedBottom(first) <= getDecoratedTop(child)) {
return first;
} else {
return child;
}
}
if (getDecoratedTop(child) < getDecoratedTop(first)) {
return child;
}
if (sfp + 1 == getPosition(child)) {
return first;
}
return child;
}
use of android.support.v7.app.ActionBar.LayoutParams in project SuperSLiM by TonicArtos.
the class LayoutManager method findAttachedHeaderForSectionFromEnd.
/**
* The header is almost guaranteed to be at the end so just use look there.
*
* @param sfp Section identifier.
* @return Header, or null if not found.
*/
private View findAttachedHeaderForSectionFromEnd(int sfp) {
for (int i = getChildCount() - 1; i >= 0; i--) {
View child = getChildAt(i);
LayoutParams params = (LayoutParams) child.getLayoutParams();
if (params.getTestedFirstPosition() != sfp) {
break;
} else if (params.isHeader) {
return child;
}
}
return null;
}
use of android.support.v7.app.ActionBar.LayoutParams in project SuperSLiM by TonicArtos.
the class LayoutManager method fillToStart.
/**
* Fill towards the start edge.
*
* @param leadingEdge Line to fill up to. Content will not be wholly beyond this line.
* @param state Layout state.
* @return Line content was filled up to.
*/
private int fillToStart(int leadingEdge, LayoutState state) {
View anchor = getAnchorAtStart();
LayoutParams anchorParams = (LayoutParams) anchor.getLayoutParams();
final int sfp = anchorParams.getTestedFirstPosition();
final View first = getHeaderOrFirstViewForSection(sfp, Direction.START, state);
final SectionData sd = new SectionData(this, first);
final SectionLayoutManager slm = getSlm(sd);
int markerLine;
int anchorPosition = getPosition(anchor);
if (anchorPosition == sd.firstPosition) {
markerLine = getDecoratedTop(anchor);
} else {
if (anchorPosition - 1 == sd.firstPosition && sd.hasHeader) {
// Already at first content position, so no more to do.
markerLine = getDecoratedTop(anchor);
} else {
markerLine = slm.finishFillToStart(leadingEdge, anchor, sd, state);
}
}
markerLine = updateHeaderForStart(first, leadingEdge, markerLine, sd, state);
if (markerLine > leadingEdge) {
markerLine = fillNextSectionToStart(leadingEdge, markerLine, state);
}
return markerLine;
}
use of android.support.v7.app.ActionBar.LayoutParams in project SuperSLiM by TonicArtos.
the class LayoutManager method scrollVerticallyBy.
@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
int numChildren = getChildCount();
if (numChildren == 0) {
return 0;
}
LayoutState layoutState = new LayoutState(this, recycler, state);
final Direction direction = dy > 0 ? Direction.END : Direction.START;
final boolean isDirectionEnd = direction == Direction.END;
final int height = getHeight();
final int leadingEdge = isDirectionEnd ? height + dy : dy;
// from the bottom up.
if (isDirectionEnd) {
final View end = getAnchorAtEnd();
LayoutParams params = (LayoutParams) end.getLayoutParams();
SectionLayoutManager slm = getSlm(params);
final int endEdge = slm.getLowestEdge(params.getTestedFirstPosition(), getChildCount() - 1, getDecoratedBottom(end));
if (endEdge < height - getPaddingBottom() && getPosition(end) == (state.getItemCount() - 1)) {
return 0;
}
}
final int fillEdge = fillUntil(leadingEdge, direction, layoutState);
final int delta;
if (isDirectionEnd) {
// Add padding so we scroll to inset area at scroll end.
int fillDelta = fillEdge - height + getPaddingBottom();
delta = fillDelta < dy ? fillDelta : dy;
} else {
int fillDelta = fillEdge - getPaddingTop();
delta = fillDelta > dy ? fillDelta : dy;
}
if (delta != 0) {
offsetChildrenVertical(-delta);
trimTail(isDirectionEnd ? Direction.START : Direction.END, layoutState);
}
layoutState.recycleCache();
return delta;
}
Aggregations