use of android.support.v7.widget.RecyclerView.Recycler in project GestureViews by alexvasilkov.
the class EndlessRecyclerAdapter method loadNextItemsIfNeeded.
private void loadNextItemsIfNeeded(RecyclerView recyclerView) {
if (!isLoading && !isError) {
View lastVisibleChild = recyclerView.getChildAt(recyclerView.getChildCount() - 1);
int lastVisiblePos = recyclerView.getChildAdapterPosition(lastVisibleChild);
int total = getItemCount();
if (lastVisiblePos >= total - loadingOffset) {
// We need to use runnable, since recycler view does not like when we are notifying
// about changes during scroll callback.
recyclerView.post(new Runnable() {
@Override
public void run() {
loadNextItems();
}
});
}
}
}
use of android.support.v7.widget.RecyclerView.Recycler in project Carbon by ZieIony.
the class IconTextListItemActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listcomponent);
Samples.initToolbar(this, getString(R.string.iconTextListItemActivity_title));
RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
recycler.setLayoutManager(new LinearLayoutManager(this));
RowListAdapter adapter = new RowListAdapter<>(DefaultIconTextItem.class, IconTextRow::new);
adapter.addFactory(DefaultIconSearchItem.class, parent -> new IconSearchRow(parent, new ArraySearchDataProvider(new String[] {}), filterResults -> {
}));
recycler.setAdapter(adapter);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(new ColorDrawable(Carbon.getThemeColor(this, R.attr.carbon_dividerColor)), getResources().getDimensionPixelSize(R.dimen.carbon_1dip));
dividerItemDecoration.setDrawRules(position -> position == 0);
recycler.addItemDecoration(dividerItemDecoration);
VectorDrawable drawable = new VectorDrawable(getResources(), R.raw.ic_face_24px);
adapter.setItems(Arrays.asList(new DefaultIconSearchItem(this), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text")));
}
use of android.support.v7.widget.RecyclerView.Recycler in project Carbon by ZieIony.
the class ImageTextSubtextDateListItemActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listcomponent);
Samples.initToolbar(this, getString(R.string.imageTextSubtextDateListItemActivity_title));
RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
recycler.setLayoutManager(new LinearLayoutManager(this));
RowListAdapter adapter = new RowListAdapter<>(DefaultImageTextSubtextDateItem.class, ImageTextSubtextDateRow::new);
adapter.addFactory(DefaultHeaderItem.class, PaddedHeaderRow.FACTORY);
recycler.setAdapter(adapter);
Drawable drawable = getResources().getDrawable(R.drawable.watermelon);
String date = format.format(new Date().getTime());
adapter.setItems(Arrays.asList(new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date)));
}
use of android.support.v7.widget.RecyclerView.Recycler 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;
}
use of android.support.v7.widget.RecyclerView.Recycler in project RecyclerRefreshLayout by dinuscxj.
the class HeaderViewRecyclerAdapter method adjustSpanSize.
public void adjustSpanSize(RecyclerView recycler) {
if (recycler.getLayoutManager() instanceof GridLayoutManager) {
final GridLayoutManager layoutManager = (GridLayoutManager) recycler.getLayoutManager();
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
boolean isHeaderOrFooter = isHeaderPosition(position) || isFooterPosition(position);
return isHeaderOrFooter ? layoutManager.getSpanCount() : 1;
}
});
}
if (recycler.getLayoutManager() instanceof StaggeredGridLayoutManager) {
this.mIsStaggeredGrid = true;
}
}
Aggregations