本文整理汇总了Java中com.nhaarman.listviewanimations.util.AdapterViewUtil类的典型用法代码示例。如果您正苦于以下问题:Java AdapterViewUtil类的具体用法?Java AdapterViewUtil怎么用?Java AdapterViewUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AdapterViewUtil类属于com.nhaarman.listviewanimations.util包,在下文中一共展示了AdapterViewUtil类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: undo
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
/**
* 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(@NonNull final View view) {
int position = AdapterViewUtil.getPositionForView(getListViewWrapper(), view);
mUndoPositions.remove(position);
View primaryView = mCallback.getPrimaryView(view);
View undoView = mCallback.getUndoView(view);
primaryView.setVisibility(View.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.getWidth(), 0f);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(undoAlphaAnimator, primaryAlphaAnimator, primaryXAnimator);
animatorSet.addListener(new UndoAnimatorListener(undoView));
animatorSet.start();
mCallback.onUndo(view, position);
}
开发者ID:sathishmscict,项目名称:ListViewAnimations,代码行数:26,代码来源:SwipeUndoTouchListener.java
示例2: fling
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
/**
* 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 void fling(final int position) {
int firstVisiblePosition = mListViewWrapper.getFirstVisiblePosition();
int lastVisiblePosition = mListViewWrapper.getLastVisiblePosition();
if (position < firstVisiblePosition || position > lastVisiblePosition) {
throw new IllegalArgumentException("View for position " + position + " not visible!");
}
View downView = AdapterViewUtil.getViewForPosition(mListViewWrapper, position);
if (downView == null) {
throw new IllegalStateException("No view found for position " + position);
}
flingView(downView, position, true);
mActiveSwipeCount++;
mVirtualListCount--;
}
开发者ID:sathishmscict,项目名称:ListViewAnimations,代码行数:23,代码来源:SwipeTouchListener.java
示例3: dismissAbove
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
private void dismissAbove(final int position) {
View view = AdapterViewUtil.getViewForPosition(getListViewWrapper(), getListViewWrapper().getFirstVisiblePosition());
if (view != null) {
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
int scrollDistance = view.getMeasuredHeight();
getListViewWrapper().smoothScrollBy(scrollDistance, (int) mDismissAnimationTime);
mHandler.postDelayed(new RestoreScrollRunnable(scrollDistance, position), mDismissAnimationTime);
}
}
开发者ID:sathishmscict,项目名称:ListViewAnimations,代码行数:12,代码来源:SwipeDismissTouchListener.java
示例4: handleDownEvent
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
private boolean handleDownEvent(@Nullable final View view, @NonNull final 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;
}
开发者ID:sathishmscict,项目名称:ListViewAnimations,代码行数:36,代码来源:SwipeTouchListener.java
示例5: findViewForPosition
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
@Nullable
private View findViewForPosition(final int position) {
if (mListViewWrapper == null) {
throw new 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;
}
开发者ID:sathishmscict,项目名称:ListViewAnimations,代码行数:16,代码来源:ExpandableListItemAdapter.java
示例6: getCurrentRemovedView
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
private ContextualUndoView getCurrentRemovedView(final ContextualUndoView currentRemovedView, final long itemId) {
ContextualUndoView result = currentRemovedView;
if (result == null ||
result.getParent() == null ||
result.getItemId() != itemId ||
AdapterViewUtil.getPositionForView(getAbsListView(), result) < 0) {
result = getContextualUndoView(itemId);
}
return result;
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:11,代码来源:ContextualUndoAdapter.java
示例7: swipeViewAtPosition
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
/**
* Animate the item at given position away and show the undo {@link View}.
* @param position the position.
*/
public void swipeViewAtPosition(final int position) {
mCurrentRemovedId = getItemId(position);
for (int i = 0; i < getAbsListView().getChildCount(); i++) {
AbsListView absListView = getAbsListView();
View childView = absListView.getChildAt(i);
int positionForView = AdapterViewUtil.getPositionForView(absListView, childView);
if (positionForView == position) {
swipeView(childView, positionForView);
}
}
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:16,代码来源:ContextualUndoAdapter.java
示例8: getVisibleViewsForPositions
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
private List<View> getVisibleViewsForPositions(final Collection<Integer> positions) {
List<View> views = new ArrayList<View>();
for (int i = 0; i < getAbsListView().getChildCount(); i++) {
View child = getAbsListView().getChildAt(i);
if (positions.contains(AdapterViewUtil.getPositionForView(getAbsListView(), child))) {
views.add(child);
}
}
return views;
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:11,代码来源:AnimateDismissAdapter.java
示例9: findViewForPosition
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
private View findViewForPosition(final int position) {
View result = null;
for (int i = 0; i < mAbsListView.getChildCount() && result == null; i++) {
View childView = mAbsListView.getChildAt(i);
if (AdapterViewUtil.getPositionForView(mAbsListView, childView) == position) {
result = childView;
}
}
return result;
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:11,代码来源:ExpandableListItemAdapter.java
示例10: handleDownEvent
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
private boolean handleDownEvent(final View view, final MotionEvent motionEvent) {
mDisallowSwipe = false;
if (mPaused) {
return false;
}
// Find the child view that was touched (perform a hit test)
Rect rect = new Rect();
int childCount = mListView.getChildCount();
int[] listViewCoords = new int[2];
mListView.getLocationOnScreen(listViewCoords);
int x = (int) motionEvent.getRawX() - listViewCoords[0];
int y = (int) motionEvent.getRawY() - listViewCoords[1];
View child;
for (int i = 0; i < childCount; i++) {
child = mListView.getChildAt(i);
child.getHitRect(rect);
if (rect.contains(x, y)) {
mDownView = child;
break;
}
}
if (mDownView != null && mDownView instanceof ContextualUndoView) {
mDownX = motionEvent.getRawX();
mDownY = motionEvent.getRawY();
int downPosition = AdapterViewUtil.getPositionForView(mListView, mDownView);
if (mDismissableManager != null) {
long downId = mListView.getAdapter().getItemId(downPosition);
if (!mDismissableManager.isDismissable(downId, downPosition)) {
/* Cancel, not dismissable */
return false;
}
}
mTouchChildTouched = !mIsParentHorizontalScrollContainer && mResIdOfTouchChild == 0;
if (mResIdOfTouchChild != 0) {
mIsParentHorizontalScrollContainer = false;
final View childView = mDownView.findViewById(mResIdOfTouchChild);
if (childView != null) {
final Rect childRect = getChildViewRect(mListView, childView);
if (childRect.contains((int) motionEvent.getX(), (int) motionEvent.getY())) {
mTouchChildTouched = true;
mListView.requestDisallowInterceptTouchEvent(true);
}
}
}
if (mIsParentHorizontalScrollContainer) {
// Do it now and don't wait until the user moves more than
// the slop factor.
mTouchChildTouched = true;
mListView.requestDisallowInterceptTouchEvent(true);
}
mDownY = motionEvent.getRawY();
mDownPosition = AdapterViewUtil.getPositionForView(mListView, mDownView);
if (mTouchChildTouched) {
mVelocityTracker = VelocityTracker.obtain();
mVelocityTracker.addMovement(motionEvent);
} else {
mVelocityTracker = null;
}
}
view.onTouchEvent(motionEvent);
return true;
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:72,代码来源:ContextualUndoListViewTouchListener.java
示例11: deleteCurrentItem
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
private void deleteCurrentItem(final View view) {
int position = AdapterViewUtil.getPositionForView(getAbsListView(), view);
mDeleteItemCallback.deleteItem(position);
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:5,代码来源:ContextualUndoAdapter.java
示例12: handleDownEvent
import com.nhaarman.listviewanimations.util.AdapterViewUtil; //导入依赖的package包/类
private boolean handleDownEvent(final MotionEvent motionEvent) {
// Find the child view that was touched (perform a hit test)
Rect rect = new Rect();
int childCount = mListView.getChildCount();
int[] listViewCoords = new int[2];
mListView.getLocationOnScreen(listViewCoords);
int x = (int) motionEvent.getRawX() - listViewCoords[0];
int y = (int) motionEvent.getRawY() - listViewCoords[1];
View downView = null;
for (int i = 0; i < childCount && downView == null; i++) {
View child = mListView.getChildAt(i);
child.getHitRect(rect);
if (rect.contains(x, y)) {
downView = child;
}
}
if (downView != null) {
mDownX = motionEvent.getRawX();
mDownY = motionEvent.getRawY();
int downPosition = AdapterViewUtil.getPositionForView(mListView, downView);
if (mDismissableManager != null) {
long downId = mListView.getAdapter().getItemId(downPosition);
if (!mDismissableManager.isDismissable(downId, downPosition)) {
/* Cancel, not dismissable */
return false;
}
}
mCurrentDismissData = createPendingDismissData(downPosition, downView);
if (mPendingDismisses.contains(mCurrentDismissData) || downPosition >= mVirtualListCount) {
// Cancel, we're already processing this position
mCurrentDismissData = null;
return false;
} else {
mTouchChildTouched = !mIsParentHorizontalScrollContainer && mResIdOfTouchChild == 0;
if (mResIdOfTouchChild != 0) {
mIsParentHorizontalScrollContainer = false;
final View childView = downView.findViewById(mResIdOfTouchChild);
if (childView != null) {
final Rect childRect = getChildViewRect(mListView, childView);
if (childRect.contains((int) motionEvent.getX(), (int) motionEvent.getY())) {
mTouchChildTouched = true;
mListView.requestDisallowInterceptTouchEvent(true);
}
}
}
if (mIsParentHorizontalScrollContainer) {
// Do it now and don't wait until the user moves more than
// the slop factor.
mTouchChildTouched = true;
mListView.requestDisallowInterceptTouchEvent(true);
}
mVelocityTracker = VelocityTracker.obtain();
mVelocityTracker.addMovement(motionEvent);
}
}
return true;
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:66,代码来源:SwipeDismissListViewTouchListener.java
注:本文中的com.nhaarman.listviewanimations.util.AdapterViewUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论