@@ -34,6 +34,7 @@ public class CollectionView : EBox, ICollectionViewController, IRotaryInteractio
3434 SmartEvent _scrollAnimationStop ;
3535 SmartEvent _scrollAnimationStart ;
3636 bool _isScrollAnimationStarted ;
37+ bool _allowFocusOnItem ;
3738
3839 public event EventHandler < ItemsViewScrolledEventArgs > Scrolled ;
3940
@@ -52,6 +53,9 @@ public CollectionView(EvasObject parent) : base(parent)
5253 _scrollAnimationStop = new SmartEvent ( Scroller , ThemeConstants . Scroller . Signals . StopScrollAnimation ) ;
5354 _scrollAnimationStop . On += OnScrollStopped ;
5455
56+ Scroller . DragStart += OnDragStart ;
57+ Scroller . KeyDown += OnKeyDown ;
58+
5559 _innerLayout = new EBox ( parent ) ;
5660 _innerLayout . SetLayoutCallback ( OnInnerLayout ) ;
5761 _innerLayout . Show ( ) ;
@@ -306,6 +310,8 @@ ViewHolder ICollectionViewController.RealizeView(int index)
306310 _innerLayout . PackEnd ( holder ) ;
307311 }
308312
313+ holder . AllowItemFocus = _allowFocusOnItem ;
314+
309315 Adaptor . SetBinding ( holder . Content , index ) ;
310316 _viewHolderIndexTable [ holder ] = index ;
311317 if ( index == SelectedItemIndex )
@@ -325,6 +331,7 @@ void OnItemStateChanged(object sender, EventArgs e)
325331
326332 if ( holder . State == ViewHolderState . Focused && FocusedItemScrollPosition != ScrollToPosition . MakeVisible )
327333 {
334+
328335 Device . BeginInvokeOnMainThread ( ( ) =>
329336 {
330337 if ( holder . State == ViewHolderState . Focused && _viewHolderIndexTable . TryGetValue ( holder , out int itemIndex ) )
@@ -363,6 +370,7 @@ void ICollectionViewController.UnrealizeView(ViewHolder view)
363370 Adaptor . UnBinding ( view . Content ) ;
364371 view . ResetState ( ) ;
365372 view . Hide ( ) ;
373+
366374 _pool . AddRecyclerView ( view ) ;
367375 if ( _lastSelectedViewHolder == view )
368376 {
@@ -661,6 +669,18 @@ void OnScrolled(object sender, EventArgs e)
661669 }
662670 }
663671
672+ void OnKeyDown ( object sender , EvasKeyEventArgs e )
673+ {
674+ _allowFocusOnItem = true ;
675+ UpdateAllowFocusOnItem ( _allowFocusOnItem ) ;
676+ }
677+
678+ void OnDragStart ( object sender , EventArgs e )
679+ {
680+ _allowFocusOnItem = false ;
681+ UpdateAllowFocusOnItem ( _allowFocusOnItem ) ;
682+ }
683+
664684 void SendScrolledEvent ( )
665685 {
666686 var args = new ItemsViewScrolledEventArgs ( ) ;
@@ -733,6 +753,14 @@ void RemoveEmptyView()
733753 Adaptor . RemoveNativeView ( _emptyView ) ;
734754 _emptyView = null ;
735755 }
756+
757+ void UpdateAllowFocusOnItem ( bool allowFocus )
758+ {
759+ foreach ( var holer in _viewHolderIndexTable )
760+ {
761+ holer . Key . AllowItemFocus = allowFocus ;
762+ }
763+ }
736764 }
737765
738766 public interface ICollectionViewController
0 commit comments