/** 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.view, this); // read layout parameters LayoutParams layoutParams = (LayoutParams)pinnedView.LayoutParameters; if (layoutParams == null) // create default layout params { layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); //layoutParams = (LayoutParams) GenerateDefaultLayoutParams (); //generateDefaultLayoutParams(); layoutParams = new 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 try{ int ws = MeasureSpec.MakeMeasureSpec(Width - ListPaddingLeft - ListPaddingRight, MeasureSpecMode.Exactly); //int hs = MeasureSpec.MakeMeasureSpec(heightSize, heightMode); int myNegInt = System.Math.Abs(heightSize) * (-1); int hs = MeasureSpec.MakeMeasureSpec(heightSize, heightMode); pinnedView.Measure(Convert.ToInt32(ws), Convert.ToInt32(hs)); } catch (Exception ex) { System.Console.WriteLine(ex.Message.ToString()); } mTranslateY = 0; pinnedView.Layout(0, 0, pinnedView.MeasuredWidth, pinnedView.MeasuredHeight); // initialize pinned shadow pinnedShadow.view = pinnedView; pinnedShadow.position = position; pinnedShadow.id = Adapter.GetItemId(position); // store pinned shadow mPinnedSection = pinnedShadow; }
/** Destroy shadow wrapper for currently pinned view */ void destroyPinnedShadow() { if (mPinnedSection != null) { // keep shadow for being recycled later 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.view, this); // read layout parameters LayoutParams layoutParams = (LayoutParams)pinnedView.LayoutParameters; if (layoutParams == null) // create default layout params { layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); } 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.view = pinnedView; pinnedShadow.position = position; pinnedShadow.id = Adapter.GetItemId(position); // store pinned shadow mPinnedSection = pinnedShadow; }
/** 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.view, this); // read layout parameters LayoutParams layoutParams = (LayoutParams) pinnedView.LayoutParameters; if (layoutParams == null) { // create default layout params layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); } 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.view = pinnedView; pinnedShadow.position = position; pinnedShadow.id = Adapter.GetItemId(position); // store pinned shadow mPinnedSection = pinnedShadow; }
/** 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.view, this); // read layout parameters LayoutParams layoutParams = (LayoutParams) pinnedView.LayoutParameters; if (layoutParams == null) { // create default layout params layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); //layoutParams = (LayoutParams) GenerateDefaultLayoutParams (); //generateDefaultLayoutParams(); layoutParams = new 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 try{ int ws = MeasureSpec.MakeMeasureSpec(Width - ListPaddingLeft - ListPaddingRight, MeasureSpecMode.Exactly); //int hs = MeasureSpec.MakeMeasureSpec(heightSize, heightMode); int myNegInt = System.Math.Abs(heightSize) * (-1); int hs = MeasureSpec.MakeMeasureSpec(heightSize, heightMode); pinnedView.Measure(Convert.ToInt32(ws), Convert.ToInt32(hs)); } catch(Exception ex){ System.Console.WriteLine (ex.Message.ToString()); } mTranslateY = 0; pinnedView.Layout(0, 0, pinnedView.MeasuredWidth, pinnedView.MeasuredHeight); // initialize pinned shadow pinnedShadow.view = pinnedView; pinnedShadow.position = position; pinnedShadow.id = Adapter.GetItemId(position); // store pinned shadow mPinnedSection = pinnedShadow; }