public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { base.GetItemOffsets(outRect, view, parent, state); if (_space <= 0) { return; } if (_addSpaceFirstItem && parent.GetChildLayoutPosition(view) < 1 || parent.GetChildLayoutPosition(view) >= 1) { if (getOrientation(parent) == LinearLayoutManager.Vertical) { outRect.Top = _space; } else { outRect.Left = _space; } } if (!_addSpaceLastItem || parent.GetChildAdapterPosition(view) != getTotalItemCount(parent) - 1) { return; } if (getOrientation(parent) == LinearLayoutManager.Vertical) { outRect.Bottom = _space; } else { outRect.Right = _space; } }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.GetChildLayoutPosition(view) != 0) { outRect.Top = Space; } }
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.FromContext(parent.Context).Inflate(Resource.Layout.item_main_feature, parent, false); view.Click += delegate { int position = recyclerView.GetChildLayoutPosition(view); var activityType = samples[position].ActivityType; if (activityType == null) { if (view.Context is MainActivity ma) { ma.DemoOptimizeTripsAPI(); } return; } Intent intent = new Intent(view.Context, activityType); view.Context.StartActivity(intent); }; return(new ViewHolder(view)); }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.GetChildLayoutPosition(view) != 0) { outRect.Top = space; } }
public void OnClick(View v) { int position = recyclerView.GetChildLayoutPosition(v); var intent = new Intent(v.Context, samples[position].Activity); recyclerView.Context.StartActivity(intent); }
public override void GetItemOffsets(Android.Graphics.Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { int position = parent.GetChildLayoutPosition(view); if (position % 2 == 0) { outRect.Right = space; } outRect.Bottom = space; }
public void OnRecycleViewItemClick(View v) { var position = recycleView.GetChildLayoutPosition(v); selectedPage = adapter.Items[position]; var intent = PageFilterActivity.CreateIntent(this, selectedPage); StartActivityForResult(intent, FILTER_UI_REQUEST_CODE); }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.GetChildLayoutPosition(view) == 1) { var pix = DPX.dpToPx(GelenBase, 90); outRect.Top = pix - space; } else { outRect.Top = space; } outRect.Bottom = space; }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { base.GetItemOffsets(outRect, view, parent, state); outRect.Left = space; outRect.Right = space; outRect.Bottom = space; // Add top margin only for the first item to avoid double space between items if (parent.GetChildLayoutPosition(view) == 0) { outRect.Top = space; } else { outRect.Top = 0; } }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { int position = parent.GetChildLayoutPosition(view); // Add top margin only for the first item to avoid double space between items if (position % 2 == 0) { outRect.Top = 0; outRect.Left = space - previous; outRect.Right = space / 2 - previous; outRect.Bottom = space - previous; } else { outRect.Top = 0; outRect.Left = space / 2 - previous; outRect.Right = space - previous; outRect.Bottom = space - previous; } if (position < 2) { outRect.Top = space - previous; } }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { RecyclerView.LayoutManager layoutManager = parent.GetLayoutManager(); if (!(layoutManager is GridLayoutManager)) { outRect.Set(0, 0, 0, 0); return; } RecyclerView.Adapter adapter = parent.GetAdapter(); if (adapter == null) { outRect.Set(0, 0, 0, 0); return; } int position = parent.GetChildLayoutPosition(view); if (position == -1) { outRect.Set(0, 0, 0, 0); return; } GridLayoutManager glm = (GridLayoutManager)layoutManager; int size = adapter.ItemCount; int span = glm.SpanCount; int spanIndex = position % span; int spanGroup = position / span; if (spanIndex == 0) { outRect.Left = margin; } else { outRect.Left = (margin + 1) / 2; } if (spanIndex == span - 1) { outRect.Right = margin; } else { outRect.Right = margin / 2; } if (spanGroup == 0) { outRect.Top = margin; } else { outRect.Top = (margin + 1) / 2; } if (spanGroup == (size - 1) / span) { outRect.Bottom = margin; } else { outRect.Bottom = margin / 2; } }
public override void OnDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { RecyclerView.Adapter adapter = parent.GetAdapter(); if (adapter == null) { return; } int itemCount = adapter.ItemCount; if (orientation == VERTICAL) { bool isRtl = ViewCompat.GetLayoutDirection(parent) == ViewCompat.LayoutDirectionRtl; int paddingLeft; int paddingRight; if (isRtl) { paddingLeft = paddingEnd; paddingRight = paddingStart; } else { paddingLeft = paddingStart; paddingRight = paddingEnd; } int left = parent.PaddingLeft + paddingLeft; int right = parent.Width - parent.PaddingRight - paddingRight; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams)child.LayoutParameters; int position = parent.GetChildLayoutPosition(child); bool show; if (showDividerHelper != null) { show = showDividerHelper.ShowDivider(position + 1); } else { show = (position != itemCount - 1) || showLastDivider; } if (show) { int top = child.Bottom + lp.BottomMargin; if (overlap) { top -= thickness; } int bottom = top + thickness; rect.Set(left, top, right, bottom); c.DrawRect(rect, paint); } if (position == 0) { if (showDividerHelper != null) { show = showDividerHelper.ShowDivider(0); } else { show = showFirstDivider; } if (show) { int bottom = child.Top + lp.TopMargin; if (overlap) { bottom += thickness; } int top = bottom - thickness; rect.Set(left, top, right, bottom); c.DrawRect(rect, paint); } } } } else { int top = parent.PaddingTop + paddingStart; int bottom = parent.Height - parent.PaddingBottom - paddingEnd; int childCount = parent.ChildCount; for (int i = 0; i < childCount; i++) { View child = parent.GetChildAt(i); RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams)child.LayoutParameters; int position = parent.GetChildLayoutPosition(child); bool show; if (showDividerHelper != null) { show = showDividerHelper.ShowDivider(position + 1); } else { show = (position != itemCount - 1) || showLastDivider; } if (show) { int left = child.Right + lp.RightMargin; if (overlap) { left -= thickness; } int right = left + thickness; rect.Set(left, top, right, bottom); c.DrawRect(rect, paint); } if (position == 0) { if (showDividerHelper != null) { show = showDividerHelper.ShowDivider(0); } else { show = showFirstDivider; } if (show) { int right = child.Left + lp.LeftMargin; if (overlap) { right += thickness; } int left = right - thickness; rect.Set(left, top, right, bottom); c.DrawRect(rect, paint); } } } } }
public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.GetAdapter() == null) { // Can't Get view position, return empty rect outRect.Set(0, 0, 0, 0); return; } if (overlap) { // Overlap, return empty rect outRect.Set(0, 0, 0, 0); return; } int position = parent.GetChildLayoutPosition(view); int itemCount = parent.GetAdapter().ItemCount; outRect.Set(0, 0, 0, 0); if (showDividerHelper != null) { if (orientation == VERTICAL) { if (position == 0 && showDividerHelper.ShowDivider(0)) { outRect.Top = thickness; } if (showDividerHelper.ShowDivider(position + 1)) { outRect.Bottom = thickness; } } else { if (position == 0 && showDividerHelper.ShowDivider(0)) { outRect.Left = thickness; } if (showDividerHelper.ShowDivider(position + 1)) { outRect.Right = thickness; } } } else { if (orientation == VERTICAL) { if (position == 0 && showFirstDivider) { outRect.Top = thickness; } if ((position != itemCount - 1) || showLastDivider) { outRect.Bottom = thickness; } } else { if (position == 0 && showFirstDivider) { outRect.Left = thickness; } if ((position != itemCount - 1) || showLastDivider) { outRect.Right = thickness; } } } }