@@ -34,6 +34,7 @@ public class CollectionView : EBox, ICollectionViewController, IRotaryInteractio
34
34
SmartEvent _scrollAnimationStop ;
35
35
SmartEvent _scrollAnimationStart ;
36
36
bool _isScrollAnimationStarted ;
37
+ bool _allowFocusOnItem ;
37
38
38
39
public event EventHandler < ItemsViewScrolledEventArgs > Scrolled ;
39
40
@@ -52,6 +53,9 @@ public CollectionView(EvasObject parent) : base(parent)
52
53
_scrollAnimationStop = new SmartEvent ( Scroller , ThemeConstants . Scroller . Signals . StopScrollAnimation ) ;
53
54
_scrollAnimationStop . On += OnScrollStopped ;
54
55
56
+ Scroller . DragStart += OnDragStart ;
57
+ Scroller . KeyDown += OnKeyDown ;
58
+
55
59
_innerLayout = new EBox ( parent ) ;
56
60
_innerLayout . SetLayoutCallback ( OnInnerLayout ) ;
57
61
_innerLayout . Show ( ) ;
@@ -306,6 +310,8 @@ ViewHolder ICollectionViewController.RealizeView(int index)
306
310
_innerLayout . PackEnd ( holder ) ;
307
311
}
308
312
313
+ holder . AllowItemFocus = _allowFocusOnItem ;
314
+
309
315
Adaptor . SetBinding ( holder . Content , index ) ;
310
316
_viewHolderIndexTable [ holder ] = index ;
311
317
if ( index == SelectedItemIndex )
@@ -325,6 +331,7 @@ void OnItemStateChanged(object sender, EventArgs e)
325
331
326
332
if ( holder . State == ViewHolderState . Focused && FocusedItemScrollPosition != ScrollToPosition . MakeVisible )
327
333
{
334
+
328
335
Device . BeginInvokeOnMainThread ( ( ) =>
329
336
{
330
337
if ( holder . State == ViewHolderState . Focused && _viewHolderIndexTable . TryGetValue ( holder , out int itemIndex ) )
@@ -363,6 +370,7 @@ void ICollectionViewController.UnrealizeView(ViewHolder view)
363
370
Adaptor . UnBinding ( view . Content ) ;
364
371
view . ResetState ( ) ;
365
372
view . Hide ( ) ;
373
+
366
374
_pool . AddRecyclerView ( view ) ;
367
375
if ( _lastSelectedViewHolder == view )
368
376
{
@@ -661,6 +669,18 @@ void OnScrolled(object sender, EventArgs e)
661
669
}
662
670
}
663
671
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
+
664
684
void SendScrolledEvent ( )
665
685
{
666
686
var args = new ItemsViewScrolledEventArgs ( ) ;
@@ -733,6 +753,14 @@ void RemoveEmptyView()
733
753
Adaptor . RemoveNativeView ( _emptyView ) ;
734
754
_emptyView = null ;
735
755
}
756
+
757
+ void UpdateAllowFocusOnItem ( bool allowFocus )
758
+ {
759
+ foreach ( var holer in _viewHolderIndexTable )
760
+ {
761
+ holer . Key . AllowItemFocus = allowFocus ;
762
+ }
763
+ }
736
764
}
737
765
738
766
public interface ICollectionViewController
0 commit comments