@@ -63,8 +63,7 @@ public enum SwipeAction
6363 None = 0 ,
6464 Reveal = 1 ,
6565 Dismiss = 2 ,
66- Choice = 3 ,
67- RevealDismiss = 4
66+ Choice = 3
6867 }
6968
7069 public enum TouchState
@@ -81,9 +80,7 @@ public enum TouchState
8180
8281 int _swipeFrontView = 0 ;
8382 int _swipeBackView = 0 ;
84- int _swipeRevealDismissView = 0 ;
8583
86- //private ISwipeListViewListener _swipeListViewListener;
8784 private SwipeListViewTouchListener _touchListener ;
8885
8986 public SwipeListView ( IntPtr ptr , JniHandleOwnership handler ) : base ( ptr , handler ) { }
@@ -108,14 +105,11 @@ private void Init(IAttributeSet attrs)
108105 long swipeAnimationTime = 0 ;
109106 float swipeOffsetLeft = 0 ;
110107 float swipeOffsetRight = 0 ;
111- float _choiceOffset = 80 ;
112- float _swipeRevealDismissThreshold = .6f ;
113108 var swipeMode = ( int ) SwipeMode . Both ;
114109 var swipeOpenOnLongPress = true ;
115110 var swipeCloseAllItemsWhenMoveList = true ;
116111 var swipeDrawableChecked = 0 ;
117112 var swipeDrawableUnchecked = 0 ;
118- var swipeAllowFling = true ;
119113
120114 var swipeActionLeft = ( int ) SwipeAction . Reveal ;
121115 var swipeActionRight = ( int ) SwipeAction . Reveal ;
@@ -128,18 +122,18 @@ private void Init(IAttributeSet attrs)
128122 swipeActionRight = styled . GetInt ( Resource . Styleable . SwipeListView_swipeActionRight , ( int ) SwipeAction . Reveal ) ;
129123 swipeOffsetLeft = styled . GetDimension ( Resource . Styleable . SwipeListView_swipeOffsetLeft , 0 ) ;
130124 swipeOffsetRight = styled . GetDimension ( Resource . Styleable . SwipeListView_swipeOffsetRight , 0 ) ;
131- _choiceOffset = styled . GetDimension ( Resource . Styleable . SwipeListView_choiceOffset , _choiceOffset ) ;
132- _swipeRevealDismissThreshold = styled . GetFloat ( Resource . Styleable . SwipeListView_swipeRevealDismissThreshold , _swipeRevealDismissThreshold ) ;
125+ // _choiceOffset = styled.GetDimension(Resource.Styleable.SwipeListView_choiceOffset, _choiceOffset);
126+ // _swipeRevealDismissThreshold = styled.GetFloat(Resource.Styleable.SwipeListView_swipeRevealDismissThreshold, _swipeRevealDismissThreshold);
133127 swipeOpenOnLongPress = styled . GetBoolean ( Resource . Styleable . SwipeListView_swipeOpenOnLongPress , swipeOpenOnLongPress ) ;
134128 swipeAnimationTime = styled . GetInt ( Resource . Styleable . SwipeListView_swipeAnimationTime , 0 ) ;
135129 swipeCloseAllItemsWhenMoveList = styled . GetBoolean ( Resource . Styleable . SwipeListView_swipeCloseAllItemsWhenMoveList , true ) ;
136130 swipeDrawableChecked = styled . GetResourceId ( Resource . Styleable . SwipeListView_swipeDrawableChecked , 0 ) ;
137131 swipeDrawableUnchecked = styled . GetResourceId ( Resource . Styleable . SwipeListView_swipeDrawableUnchecked , 0 ) ;
138- swipeAllowFling = styled . GetBoolean ( Resource . Styleable . SwipeListView_swipeAllowFling , swipeAllowFling ) ;
132+ // swipeAllowFling = styled.GetBoolean(Resource.Styleable.SwipeListView_swipeAllowFling, swipeAllowFling);
139133
140134 _swipeFrontView = styled . GetResourceId ( Resource . Styleable . SwipeListView_swipeFrontView , 0 ) ;
141135 _swipeBackView = styled . GetResourceId ( Resource . Styleable . SwipeListView_swipeBackView , 0 ) ;
142- _swipeRevealDismissView = styled . GetResourceId ( Resource . Styleable . SwipeListView_swipeRevealDismissView , 0 ) ;
136+ // _swipeRevealDismissView = styled.GetResourceId(Resource.Styleable.SwipeListView_swipeRevealDismissView, 0);
143137 }
144138
145139 if ( _swipeFrontView == 0 || _swipeBackView == 0 ) {
@@ -153,23 +147,23 @@ private void Init(IAttributeSet attrs)
153147
154148 ViewConfiguration configuration = ViewConfiguration . Get ( Context ) ;
155149 touchSlop = ViewConfigurationCompat . GetScaledPagingTouchSlop ( configuration ) ;
156- _touchListener = new SwipeListViewTouchListener ( this , _swipeFrontView , _swipeBackView , _swipeRevealDismissView ) ;
150+ _touchListener = new SwipeListViewTouchListener ( this , _swipeFrontView , _swipeBackView ) ;
157151
158152 if ( swipeAnimationTime > 0 ) {
159153 _touchListener . AnimationTime = swipeAnimationTime ;
160154 }
161155 _touchListener . RightOffset = swipeOffsetRight ;
162156 _touchListener . LeftOffset = swipeOffsetLeft ;
163- _touchListener . ChoiceOffset = _choiceOffset ;
164- _touchListener . RevealDismissThreshold = _swipeRevealDismissThreshold ;
157+ // _touchListener.ChoiceOffset = _choiceOffset;
158+ // _touchListener.RevealDismissThreshold = _swipeRevealDismissThreshold;
165159 _touchListener . SwipeActionLeft = swipeActionLeft ;
166160 _touchListener . SwipeActionRight = swipeActionRight ;
167161 _touchListener . SwipeMode = swipeMode ;
168162 _touchListener . SwipeClosesAllItemsWhenListMoves = swipeCloseAllItemsWhenMoveList ;
169163 _touchListener . SwipeOpenOnLongPress = swipeOpenOnLongPress ;
170164 _touchListener . SwipeDrawableChecked = swipeDrawableChecked ;
171165 _touchListener . SwipeDrawableUnchecked = swipeDrawableUnchecked ;
172- _touchListener . SwipeAllowFling = swipeAllowFling ;
166+ // _touchListener.SwipeAllowFling = swipeAllowFling;
173167 SetOnTouchListener ( _touchListener ) ;
174168 SetOnScrollListener ( _touchListener ) ;
175169 }
@@ -181,7 +175,15 @@ private void Init(IAttributeSet attrs)
181175 /// <param name="position">Position.</param>
182176 public void Recycle ( View convertView , int position ) {
183177 _touchListener . ReloadChoiceStateInView ( convertView . FindViewById ( _swipeFrontView ) , position ) ;
184- _touchListener . ReloadSwipeStateInView ( convertView . FindViewById ( _swipeFrontView ) ) ;
178+ _touchListener . ReloadSwipeStateInView ( convertView . FindViewById ( _swipeFrontView ) , position ) ;
179+
180+ // Clean pressed state (if dismiss is fire from a cell, to this cell, with a press drawable, in a swipelistview
181+ // when this cell will be recycle it will still have his pressed state. This ensure the pressed state is
182+ // cleaned.
183+ for ( int j = 0 ; j < ( ( ViewGroup ) convertView ) . ChildCount ; ++ j ) {
184+ View nextChild = ( ( ViewGroup ) convertView ) . GetChildAt ( j ) ;
185+ nextChild . Pressed = false ;
186+ }
185187 }
186188
187189 /// <summary>
@@ -253,6 +255,64 @@ public override IListAdapter Adapter
253255 }
254256 }
255257 }
258+
259+
260+ /// <summary>
261+ /// Dismiss the specified position.
262+ /// </summary>
263+ /// <param name="position">Position.</param>
264+ public void Dismiss ( int position ) {
265+ int height = _touchListener . Dismiss ( position ) ;
266+ if ( height > 0 ) {
267+ _touchListener . HandlerPendingDismisses ( height ) ;
268+ } else {
269+ int [ ] dismissPositions = new int [ 1 ] ;
270+ dismissPositions [ 0 ] = position ;
271+ OnDismiss ( dismissPositions ) ;
272+ _touchListener . ResetPendingDismisses ( ) ;
273+ }
274+ }
275+
276+ /// <summary>
277+ /// Dismisses items selected.
278+ /// </summary>
279+ public void DismissSelected ( ) {
280+ List < int > list = _touchListener . PositionsSelected ;
281+ int [ ] dismissPositions = new int [ list . Count ] ;
282+ int height = 0 ;
283+ for ( int i = 0 ; i < list . Count ; i ++ ) {
284+ int position = list [ i ] ;
285+ dismissPositions [ i ] = position ;
286+ int auxHeight = _touchListener . Dismiss ( position ) ;
287+ if ( auxHeight > 0 ) {
288+ height = auxHeight ;
289+ }
290+ }
291+ if ( height > 0 ) {
292+ _touchListener . HandlerPendingDismisses ( height ) ;
293+ } else {
294+ OnDismiss ( dismissPositions ) ;
295+ _touchListener . ResetPendingDismisses ( ) ;
296+ }
297+ _touchListener . ReturnOldActions ( ) ;
298+ }
299+
300+ /// <summary>
301+ /// Opens the animate.
302+ /// </summary>
303+ /// <param name="position">Position.</param>
304+ public void OpenAnimate ( int position ) {
305+ _touchListener . OpenAnimate ( position ) ;
306+ }
307+
308+ /// <summary>
309+ /// Closes the animate.
310+ /// </summary>
311+ /// <param name="position">Position.</param>
312+ public void CloseAnimate ( int position ) {
313+ _touchListener . CloseAnimate ( position ) ;
314+ }
315+
256316 #endregion
257317
258318 /// Notifies OnDismiss
0 commit comments