use of android.support.v7.widget.RecyclerView.LayoutManager in project TinyDancer by friendlyrobotnyc.
the class FPSRecyclerView method onFinishInflate.
@Override
protected void onFinishInflate() {
super.onFinishInflate();
ButterKnife.bind(this);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
setLayoutManager(layoutManager);
addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL_LIST));
setAdapter(adapter);
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project MaterialViewPager by florent37.
the class Utils method scrollTo.
public static void scrollTo(Object scroll, float yOffset) {
if (scroll instanceof RecyclerView) {
//RecyclerView.scrollTo : UnsupportedOperationException
//Moved to the RecyclerView.LayoutManager.scrollToPositionWithOffset
//Have to be instanceOf RecyclerView.LayoutManager to work (so work with RecyclerView.GridLayoutManager)
final RecyclerView.LayoutManager layoutManager = ((RecyclerView) scroll).getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
linearLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
staggeredGridLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
}
} else if (scroll instanceof NestedScrollView) {
((NestedScrollView) scroll).scrollTo(0, (int) yOffset);
}
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project RecyclerView-FlexibleDivider by yqritc.
the class FlexibleDividerDecoration method getGroupIndex.
/**
* Returns a group index for GridLayoutManager.
* for LinearLayoutManager, always returns position.
*
* @param position current view position to draw divider
* @param parent RecyclerView
* @return group index of items
*/
private int getGroupIndex(int position, RecyclerView parent) {
if (parent.getLayoutManager() instanceof GridLayoutManager) {
GridLayoutManager layoutManager = (GridLayoutManager) parent.getLayoutManager();
GridLayoutManager.SpanSizeLookup spanSizeLookup = layoutManager.getSpanSizeLookup();
int spanCount = layoutManager.getSpanCount();
return spanSizeLookup.getSpanGroupIndex(position, spanCount);
}
return position;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project RecyclerView-FlexibleDivider by yqritc.
the class FlexibleDividerDecoration method wasDividerAlreadyDrawn.
/**
* Determines whether divider was already drawn for the row the item is in,
* effectively only makes sense for a grid
*
* @param position current view position to draw divider
* @param parent RecyclerView
* @return true if the divider can be skipped as it is in the same row as the previous one.
*/
private boolean wasDividerAlreadyDrawn(int position, RecyclerView parent) {
if (parent.getLayoutManager() instanceof GridLayoutManager) {
GridLayoutManager layoutManager = (GridLayoutManager) parent.getLayoutManager();
GridLayoutManager.SpanSizeLookup spanSizeLookup = layoutManager.getSpanSizeLookup();
int spanCount = layoutManager.getSpanCount();
return spanSizeLookup.getSpanIndex(position, spanCount) > 0;
}
return false;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project Android-SpinKit by ybq.
the class Page1Fragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4);
layoutManager.setOrientation(GridLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(new RecyclerView.Adapter<Holder>() {
@Override
public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
@SuppressLint("InflateParams") View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list, null);
return new Holder(view);
}
@Override
public void onBindViewHolder(Holder holder, int position) {
holder.bind(position);
}
@Override
public int getItemCount() {
return Style.values().length;
}
});
}
Aggregations