@@ -15,7 +15,7 @@ import {
1515 profile ,
1616} from '@nativescript/core' ;
1717import { layout } from '@nativescript/core/utils/utils' ;
18- import { CollectionViewItemDisplayEventData , CollectionViewItemEventData , Orientation , reorderingEnabledProperty , reverseLayoutProperty } from './collectionview' ;
18+ import { CollectionViewItemDisplayEventData , CollectionViewItemEventData , Orientation , reorderLongPressEnabledProperty , reorderingEnabledProperty , reverseLayoutProperty } from './collectionview' ;
1919import { CLog , CLogTypes , CollectionViewBase , ListViewViewTypes , isScrollEnabledProperty , orientationProperty } from './collectionview-common' ;
2020
2121export * from './collectionview-common' ;
@@ -567,15 +567,8 @@ export class CollectionView extends CollectionViewBase {
567567
568568 _longPressGesture : androidx . core . view . GestureDetectorCompat ;
569569 _itemTouchListerner : androidx . recyclerview . widget . RecyclerView . OnItemTouchListener ;
570- public [ reorderingEnabledProperty . setNative ] ( value : boolean ) {
570+ public [ reorderLongPressEnabledProperty . setNative ] ( value : boolean ) {
571571 if ( value ) {
572- if ( ! this . _simpleItemTouchCallback ) {
573- const ItemTouchHelper = androidx . recyclerview . widget . ItemTouchHelper ;
574- this . _simpleItemTouchCallback = new SimpleCallback ( ItemTouchHelper . UP | ItemTouchHelper . DOWN | ItemTouchHelper . START | ItemTouchHelper . END , 0 ) ;
575- this . _simpleItemTouchCallback . owner = new WeakRef ( this ) ;
576- this . _itemTouchHelper = new androidx . recyclerview . widget . ItemTouchHelper ( this . _simpleItemTouchCallback ) ;
577- this . _itemTouchHelper . attachToRecyclerView ( this . nativeViewProtected ) ;
578- }
579572 if ( ! this . _longPressGesture ) {
580573 this . _longPressGesture = new androidx . core . view . GestureDetectorCompat ( this . _context , new LongPressGestureListenerImpl ( new WeakRef ( this ) ) ) ;
581574 this . _itemTouchListerner = new androidx . recyclerview . widget . RecyclerView . OnItemTouchListener ( {
@@ -590,7 +583,22 @@ export class CollectionView extends CollectionViewBase {
590583 onRequestDisallowInterceptTouchEvent :( disallowIntercept : boolean ) => {
591584 }
592585 } ) ;
593- this . nativeViewProtected . addOnItemTouchListener ( this . _itemTouchListerner ) ;
586+ }
587+ this . nativeViewProtected . addOnItemTouchListener ( this . _itemTouchListerner ) ;
588+ } else {
589+ if ( this . _itemTouchListerner ) {
590+ this . nativeViewProtected . removeOnItemTouchListener ( this . _itemTouchListerner ) ;
591+ }
592+ }
593+ }
594+ public [ reorderingEnabledProperty . setNative ] ( value : boolean ) {
595+ if ( value ) {
596+ if ( ! this . _simpleItemTouchCallback ) {
597+ const ItemTouchHelper = androidx . recyclerview . widget . ItemTouchHelper ;
598+ this . _simpleItemTouchCallback = new SimpleCallback ( ItemTouchHelper . UP | ItemTouchHelper . DOWN | ItemTouchHelper . START | ItemTouchHelper . END , 0 ) ;
599+ this . _simpleItemTouchCallback . owner = new WeakRef ( this ) ;
600+ this . _itemTouchHelper = new androidx . recyclerview . widget . ItemTouchHelper ( this . _simpleItemTouchCallback ) ;
601+ this . _itemTouchHelper . attachToRecyclerView ( this . nativeViewProtected ) ;
594602 }
595603 }
596604 }
0 commit comments