/** Destroy shadow wrapper for currently pinned view */ public void DestroyPinnedShadow() { // keep shadow for being recycled later mRecycleShadow = mPinnedShadow; mPinnedShadow = null; }
/** Create shadow wrapper with a pinned view for a view at given position */ private void CreatePinnedShadow(int position) { // try to recycle shadow PinnedViewShadow pinnedShadow = mRecycleShadow; mRecycleShadow = null; // create new shadow, if needed if (pinnedShadow == null) pinnedShadow = new PinnedViewShadow (); // request new view using recycled view, if such View pinnedView = Adapter.GetView (position, pinnedShadow.View, this); // read layout parameters LayoutParams layoutParams = (LayoutParams)pinnedView.LayoutParameters; int heightSize; MeasureSpecMode heightMode; if (layoutParams == null) { // take care for missing layout parameters heightMode = MeasureSpecMode.AtMost; heightSize = Height; } else { heightMode = MeasureSpec.GetMode (layoutParams.Height); heightSize = MeasureSpec.GetSize (layoutParams.Height); } if (heightMode == MeasureSpecMode.Unspecified) heightMode = MeasureSpecMode.Exactly; int maxHeight = Height - ListPaddingTop - ListPaddingBottom; if (heightSize > maxHeight) heightSize = maxHeight; // measure & layout int ws = MeasureSpec.MakeMeasureSpec (Width - ListPaddingLeft - ListPaddingRight, MeasureSpecMode.Exactly); int hs = MeasureSpec.MakeMeasureSpec (heightSize, heightMode); pinnedView.Measure (ws, hs); pinnedView.Layout (0, 0, pinnedView.MeasuredWidth, pinnedView.MeasuredHeight); mTranslateY = 0; // initialize pinned shadow pinnedShadow.Position = position; pinnedShadow.View = pinnedView; // store pinned shadow mPinnedShadow = pinnedShadow; }