use of com.github.florent37.materialviewpager.MaterialViewPagerAnimator in project easy by MehdiBenmesa.
the class MaterialViewPagerHeaderDecorator method getItemOffsets.
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView recyclerView, RecyclerView.State state) {
final RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
final Context context = recyclerView.getContext();
if (!registered) {
MaterialViewPagerHelper.registerRecyclerView(context, recyclerView);
registered = true;
}
int headerCells = 1;
// don't work with stagged
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
headerCells = gridLayoutManager.getSpanCount();
}
MaterialViewPagerAnimator animator = MaterialViewPagerHelper.getAnimator(context);
if (animator != null) {
if (holder.getAdapterPosition() < headerCells) {
outRect.top = Math.round(Utils.dpToPx(animator.getHeaderHeight() + 10, context));
}
}
}
use of com.github.florent37.materialviewpager.MaterialViewPagerAnimator in project MaterialViewPager by florent37.
the class MaterialViewPagerHeaderDecorator method getItemOffsets.
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView recyclerView, RecyclerView.State state) {
final RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(view);
final Context context = recyclerView.getContext();
if (!registered) {
MaterialViewPagerHelper.registerRecyclerView(context, recyclerView);
registered = true;
}
int headerCells = 1;
// don't work with stagged
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof GridLayoutManager) {
GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
headerCells = gridLayoutManager.getSpanCount();
}
MaterialViewPagerAnimator animator = MaterialViewPagerHelper.getAnimator(context);
if (animator != null) {
if (holder.getAdapterPosition() < headerCells) {
outRect.top = Math.round(Utils.dpToPx(animator.getHeaderHeight() + 10, context));
}
}
}
Aggregations