private void dismissAbove(int position) { View view = AdapterViewUtil.getViewForPosition(getListViewWrapper(), getListViewWrapper().getFirstVisiblePosition()); if (view != null) { view.Measure(View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified)); int scrollDistance = view.MeasuredHeight; getListViewWrapper().smoothScrollBy(scrollDistance, (int)mDismissAnimationTime); mHandler.PostDelayed(new RestoreScrollRunnable(scrollDistance, position, this), mDismissAnimationTime); } }
//@Nullable private View findViewForPosition(int position) { if (mListViewWrapper == null) { throw new Java.Lang.IllegalStateException("Call setAbsListView on this ExpanableListItemAdapter!"); } View result = null; for (int i = 0; i < mListViewWrapper.getChildCount() && result == null; i++) { View childView = mListViewWrapper.getChildAt(i); if (childView != null && AdapterViewUtil.getPositionForView(mListViewWrapper, childView) == position) { result = childView; } } return(result); }
private bool handleDownEvent(View view, MotionEvent motionEvent) { if (!mSwipeEnabled) { return(false); } View downView = findDownView(motionEvent); if (downView == null) { return(false); } int downPosition = AdapterViewUtil.getPositionForView(mListViewWrapper, downView); mCanDismissCurrent = isDismissable(downPosition); /* Check if we are processing the item at this position */ if (mCurrentPosition == downPosition || downPosition >= mVirtualListCount) { return(false); } if (view != null) { view.OnTouchEvent(motionEvent); } disableHorizontalScrollContainerIfNecessary(motionEvent, downView); mDownX = motionEvent.GetX(); mDownY = motionEvent.GetY(); mCurrentView = downView; mSwipingView = getSwipeView(downView); mCurrentPosition = downPosition; mVelocityTracker = VelocityTracker.Obtain(); mVelocityTracker.AddMovement(motionEvent); return(true); }
/** * Flings the {@link android.view.View} corresponding to given position out of sight. * Calling this method has the same effect as manually swiping an item off the screen. * * @param position the position of the item in the {@link android.widget.ListAdapter}. Must be visible. */ public virtual void fling(int position) { int firstVisiblePosition = mListViewWrapper.getFirstVisiblePosition(); int lastVisiblePosition = mListViewWrapper.getLastVisiblePosition(); if (position < firstVisiblePosition || position > lastVisiblePosition) { throw new Java.Lang.IllegalArgumentException("View for position " + position + " not visible!"); } View downView = AdapterViewUtil.getViewForPosition(mListViewWrapper, position); if (downView == null) { throw new Java.Lang.IllegalStateException("No view found for position " + position); } flingView(downView, position, true); mActiveSwipeCount++; mVirtualListCount--; }
/** * Performs the undo animation and restores the original state for given {@link android.view.View}. * * @param view the parent {@code View} which contains both primary and undo {@code View}s. */ public void undo(View view) { int position = AdapterViewUtil.getPositionForView(getListViewWrapper(), view); mUndoPositions.Remove(position); View primaryView = mCallback.getPrimaryView(view); View undoView = mCallback.getUndoView(view); primaryView.Visibility = ViewStates.Visible; ObjectAnimator undoAlphaAnimator = ObjectAnimator.OfFloat(undoView, ALPHA, 1f, 0f); ObjectAnimator primaryAlphaAnimator = ObjectAnimator.OfFloat(primaryView, ALPHA, 0f, 1f); ObjectAnimator primaryXAnimator = ObjectAnimator.OfFloat(primaryView, TRANSLATION_X, primaryView.Width, 0f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(undoAlphaAnimator, primaryAlphaAnimator, primaryXAnimator); animatorSet.AddListener(new UndoAnimatorListener(undoView, this)); animatorSet.Start(); mCallback.onUndo(view, position); }