@@ -610,6 +610,10 @@ private bool UpdateAnchorFromChildren(FlexibleView.Recycler recycler, AnchorInfo
610
610
}
611
611
612
612
FlexibleView . ViewHolder anchorChild = FindFirstCompleteVisibleItemView ( ) ;
613
+ if ( anchorChild != null )
614
+ {
615
+ return false ;
616
+ }
613
617
anchorInfo . Position = anchorChild . LayoutPosition ;
614
618
anchorInfo . Coordinate = mOrientationHelper . GetViewHolderStart ( anchorChild ) ;
615
619
@@ -721,26 +725,32 @@ private void Cache(FlexibleView.Recycler recycler, LayoutState layoutState, bool
721
725
FlexibleView . ViewHolder child = GetChildClosestToEnd ( ) ;
722
726
//Log.Fatal("TV.FLUX.Component", $"==========> child:{child.LayoutGroupIndex}-{child.LayoutItemIndex} childEnd:{orientationHelper.GetItemEnd(child)} # {orientationHelper.GetEnd()}");
723
727
724
- if ( child . ItemView . Focusable == false || mOrientationHelper . GetViewHolderEnd ( child ) + scrolled < mOrientationHelper . GetEnd ( ) )
728
+ if ( child != null )
725
729
{
726
- layoutState . Available = MAX_SCROLL_FACTOR * mOrientationHelper . GetTotalSpace ( ) ;
727
- layoutState . Extra = 0 ;
728
- layoutState . ScrollingOffset = LayoutState . SCROLLING_OFFSET_NaN ;
729
- layoutState . Recycle = false ;
730
- Fill ( recycler , layoutState , true , immediate ) ;
730
+ if ( child . ItemView . Focusable == false || mOrientationHelper . GetViewHolderEnd ( child ) + scrolled < mOrientationHelper . GetEnd ( ) )
731
+ {
732
+ layoutState . Available = MAX_SCROLL_FACTOR * mOrientationHelper . GetTotalSpace ( ) ;
733
+ layoutState . Extra = 0 ;
734
+ layoutState . ScrollingOffset = LayoutState . SCROLLING_OFFSET_NaN ;
735
+ layoutState . Recycle = false ;
736
+ Fill ( recycler , layoutState , true , immediate ) ;
737
+ }
731
738
}
732
739
}
733
740
else
734
741
{
735
742
FlexibleView . ViewHolder child = GetChildClosestToStart ( ) ;
736
743
737
- if ( child . ItemView . Focusable == false || mOrientationHelper . GetViewHolderStart ( child ) + scrolled > 0 )
744
+ if ( child != null )
738
745
{
739
- layoutState . Available = MAX_SCROLL_FACTOR * mOrientationHelper . GetTotalSpace ( ) ;
740
- layoutState . Extra = 0 ;
741
- layoutState . ScrollingOffset = LayoutState . SCROLLING_OFFSET_NaN ;
742
- layoutState . Recycle = false ;
743
- Fill ( recycler , layoutState , true , immediate ) ;
746
+ if ( child . ItemView . Focusable == false || mOrientationHelper . GetViewHolderStart ( child ) + scrolled > 0 )
747
+ {
748
+ layoutState . Available = MAX_SCROLL_FACTOR * mOrientationHelper . GetTotalSpace ( ) ;
749
+ layoutState . Extra = 0 ;
750
+ layoutState . ScrollingOffset = LayoutState . SCROLLING_OFFSET_NaN ;
751
+ layoutState . Recycle = false ;
752
+ Fill ( recycler , layoutState , true , immediate ) ;
753
+ }
744
754
}
745
755
}
746
756
}
@@ -866,32 +876,38 @@ private void UpdateLayoutState(int layoutDirection, float requiredSpace, bool ca
866
876
{
867
877
mLayoutState . Extra = 0 ;
868
878
mLayoutState . LayoutDirection = layoutDirection ;
869
- float scrollingOffset ;
879
+ float scrollingOffset = 0.0f ;
870
880
if ( layoutDirection == LayoutState . LAYOUT_END )
871
881
{
872
882
mLayoutState . Extra += mOrientationHelper . GetEndPadding ( ) ;
873
883
// get the first child in the direction we are going
874
884
FlexibleView . ViewHolder child = GetChildClosestToEnd ( ) ;
875
- // the direction in which we are traversing children
876
- mLayoutState . ItemDirection = mShouldReverseLayout ? LayoutState . ITEM_DIRECTION_HEAD
877
- : LayoutState . ITEM_DIRECTION_TAIL ;
878
- mLayoutState . CurrentPosition = child . LayoutPosition + mLayoutState . ItemDirection ;
879
- mLayoutState . Offset = mOrientationHelper . GetViewHolderEnd ( child ) ;
880
- // calculate how much we can scroll without adding new children (independent of layout)
881
- scrollingOffset = mOrientationHelper . GetViewHolderEnd ( child )
882
- - mOrientationHelper . GetEndAfterPadding ( ) ;
885
+ if ( child != null )
886
+ {
887
+ // the direction in which we are traversing children
888
+ mLayoutState . ItemDirection = mShouldReverseLayout ? LayoutState . ITEM_DIRECTION_HEAD
889
+ : LayoutState . ITEM_DIRECTION_TAIL ;
890
+ mLayoutState . CurrentPosition = child . LayoutPosition + mLayoutState . ItemDirection ;
891
+ mLayoutState . Offset = mOrientationHelper . GetViewHolderEnd ( child ) ;
892
+ // calculate how much we can scroll without adding new children (independent of layout)
893
+ scrollingOffset = mOrientationHelper . GetViewHolderEnd ( child )
894
+ - mOrientationHelper . GetEndAfterPadding ( ) ;
895
+ }
883
896
884
897
}
885
898
else
886
899
{
887
900
mLayoutState . Extra += mOrientationHelper . GetStartAfterPadding ( ) ;
888
901
FlexibleView . ViewHolder child = GetChildClosestToStart ( ) ;
889
- mLayoutState . ItemDirection = mShouldReverseLayout ? LayoutState . ITEM_DIRECTION_TAIL
890
- : LayoutState . ITEM_DIRECTION_HEAD ;
891
- mLayoutState . CurrentPosition = child . LayoutPosition + mLayoutState . ItemDirection ;
892
- mLayoutState . Offset = mOrientationHelper . GetViewHolderStart ( child ) ;
893
- scrollingOffset = - mOrientationHelper . GetViewHolderStart ( child )
894
- + mOrientationHelper . GetStartAfterPadding ( ) ;
902
+ if ( child != null )
903
+ {
904
+ mLayoutState . ItemDirection = mShouldReverseLayout ? LayoutState . ITEM_DIRECTION_TAIL
905
+ : LayoutState . ITEM_DIRECTION_HEAD ;
906
+ mLayoutState . CurrentPosition = child . LayoutPosition + mLayoutState . ItemDirection ;
907
+ mLayoutState . Offset = mOrientationHelper . GetViewHolderStart ( child ) ;
908
+ scrollingOffset = - mOrientationHelper . GetViewHolderStart ( child )
909
+ + mOrientationHelper . GetStartAfterPadding ( ) ;
910
+ }
895
911
}
896
912
mLayoutState . Available = requiredSpace ;
897
913
if ( canUseExistingSpace )
0 commit comments