void DestroyPinnedShadow() { if (mPinnedSection != null) { mRecycleSection = mPinnedSection; mPinnedSection = null; } }
/** Create shadow wrapper with a pinned view for a view at given position */ void CreatePinnedShadow(int position) { // try to recycle shadow PinnedSection pinnedShadow = mRecycleSection; mRecycleSection = null; // create new shadow, if needed if (pinnedShadow == null) { pinnedShadow = new PinnedSection(); } // request new view using recycled view, if such View pinnedView = Adapter.GetView(position, pinnedShadow.ViewHolder, this); // read layout parameters LayoutParams layoutParams = (LayoutParams)pinnedView.LayoutParameters; if (layoutParams == null) { layoutParams = (LayoutParams)GenerateDefaultLayoutParams(); pinnedView.LayoutParameters = layoutParams; } MeasureSpecMode heightMode = MeasureSpec.GetMode(layoutParams.Height); int 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.ViewHolder = pinnedView; pinnedShadow.Position = position; pinnedShadow.ID = Adapter.GetItemId(position); // store pinned shadow mPinnedSection = pinnedShadow; }