当前位置: 首页>>代码示例>>Java>>正文


Java CustomRecyclerViewUtils类代码示例

本文整理汇总了Java中com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils的典型用法代码示例。如果您正苦于以下问题:Java CustomRecyclerViewUtils类的具体用法?Java CustomRecyclerViewUtils怎么用?Java CustomRecyclerViewUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CustomRecyclerViewUtils类属于com.h6ah4i.android.widget.advrecyclerview.utils包,在下文中一共展示了CustomRecyclerViewUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleActionDown

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
private boolean handleActionDown(RecyclerView rv, MotionEvent e) {

        final RecyclerView.ViewHolder holder = CustomRecyclerViewUtils.findChildViewHolderUnderWithoutTranslation(rv, e.getX(), e.getY());

        if (!checkTouchedItemState(rv, holder)) {
            return false;
        }

        final int orientation = CustomRecyclerViewUtils.getOrientation(mRecyclerView);
        final int spanCount = CustomRecyclerViewUtils.getSpanCount(mRecyclerView);

        mInitialTouchX = mLastTouchX = (int) (e.getX() + 0.5f);
        mInitialTouchY = mLastTouchY = (int) (e.getY() + 0.5f);
        mInitialTouchItemId = holder.getItemId();
        mCanDragH = (orientation == CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL) ||
                ((orientation == CustomRecyclerViewUtils.ORIENTATION_VERTICAL) && (spanCount > 1));
        mCanDragV = (orientation == CustomRecyclerViewUtils.ORIENTATION_VERTICAL) ||
                ((orientation == CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL) && (spanCount > 1));


        if (mInitiateOnLongPress) {
            mHandler.startLongPressDetection(e, mLongPressTimeout);
        }

        return true;
    }
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:27,代码来源:RecyclerViewDragDropManager.java

示例2: updateDragDirectionMask

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
private void updateDragDirectionMask() {
    if (CustomRecyclerViewUtils.getOrientation(mRecyclerView) == CustomRecyclerViewUtils.ORIENTATION_VERTICAL) {
        if (((mDragStartTouchY - mDragMinTouchY) > mScrollTouchSlop) ||
                ((mDragMaxTouchY - mLastTouchY) > mScrollTouchSlop)) {
            mScrollDirMask |= SCROLL_DIR_UP;
        }
        if (((mDragMaxTouchY - mDragStartTouchY) > mScrollTouchSlop) ||
                ((mLastTouchY - mDragMinTouchY) > mScrollTouchSlop)) {
            mScrollDirMask |= SCROLL_DIR_DOWN;
        }
    } else if (CustomRecyclerViewUtils.getOrientation(mRecyclerView) == CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL) {
        if (((mDragStartTouchX - mDragMinTouchX) > mScrollTouchSlop) ||
                ((mDragMaxTouchX - mLastTouchX) > mScrollTouchSlop)) {
            mScrollDirMask |= SCROLL_DIR_LEFT;
        }
        if (((mDragMaxTouchX - mDragStartTouchX) > mScrollTouchSlop) ||
                ((mLastTouchX - mDragMinTouchX) > mScrollTouchSlop)) {
            mScrollDirMask |= SCROLL_DIR_RIGHT;
        }
    }
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:22,代码来源:RecyclerViewDragDropManager.java

示例3: start

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
public void start(MotionEvent e, DraggingItemInfo draggingItemInfo) {
    if (mStarted) {
        return;
    }

    final View itemView = mDraggingItemViewHolder.itemView;

    mDraggingItemInfo = draggingItemInfo;
    mDraggingItemImage = createDraggingItemImage(itemView, mShadowDrawable);

    mTranslationLeftLimit = mRecyclerView.getPaddingLeft();
    mTranslationTopLimit = mRecyclerView.getPaddingTop();
    mLayoutOrientation = CustomRecyclerViewUtils.getOrientation(mRecyclerView);

    // hide
    itemView.setVisibility(View.INVISIBLE);

    update(e);

    mRecyclerView.addItemDecoration(this);

    mStarted = true;
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:24,代码来源:DraggingItemDecorator.java

示例4: startSwiping

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
private void startSwiping(RecyclerView rv, MotionEvent e, RecyclerView.ViewHolder holder, int itemPosition) {
    mSwipingItem = holder;
    mSwipingItemPosition = itemPosition;
    mLastTouchX = (int) (e.getX() + 0.5f);
    mTouchedItemOffsetX = mLastTouchX;
    CustomRecyclerViewUtils.getLayoutMargins(holder.itemView, mSwipingItemMargins);

    mSwipingItemOperator = new SwipingItemOperator(this, mSwipingItem, mSwipingItemPosition, mSwipingItemReactionType);
    mSwipingItemOperator.start();

    mVelocityTracker.clear();
    mVelocityTracker.addMovement(e);

    mRecyclerView.getParent().requestDisallowInterceptTouchEvent(true);

    // raise onSwipeItemStarted() event
    mAdapter.onSwipeItemStarted(this, holder, itemPosition);
}
 
开发者ID:WriterOfAlicrow,项目名称:OpenCVTour,代码行数:19,代码来源:RecyclerViewSwipeManager.java

示例5: startSwiping

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
private void startSwiping(RecyclerView rv, MotionEvent e, RecyclerView.ViewHolder holder, int itemPosition) {
    mSwipingItem = holder;
    mSwipingItemPosition = itemPosition;
    mLastTouchX = (int) (e.getX() + 0.5f);
    mTouchedItemOffsetX = mLastTouchX;
    CustomRecyclerViewUtils.getLayoutMargins(holder.itemView, mSwipingItemMargins);

    mSwipingItemOperator = new SwipingItemOperator(this, mSwipingItem, mSwipingItemPosition, mSwipingItemReactionType);
    mSwipingItemOperator.start();

    mVelocityTracker.clear();
    mVelocityTracker.addMovement(e);

    mRecyclerView.getParent().requestDisallowInterceptTouchEvent(true);

    // raise onItemSwipeStarted() event
    if (mItemSwipeEventListener != null) {
        mItemSwipeEventListener.onItemSwipeStarted(itemPosition);
    }

    // raise onSwipeItemStarted() event
    mAdapter.onSwipeItemStarted(this, holder, itemPosition);
}
 
开发者ID:pczhu,项目名称:android-advancedrecyclerview-master,代码行数:24,代码来源:RecyclerViewSwipeManager.java

示例6: handleActionDown

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
private boolean handleActionDown(RecyclerView rv, MotionEvent e) {

        final RecyclerView.ViewHolder holder = CustomRecyclerViewUtils.findChildViewHolderUnderWithoutTranslation(rv, e.getX(), e.getY());

        if (!checkTouchedItemState(rv, holder)) {
            return false;
        }

        mInitialTouchY = mLastTouchY = (int) (e.getY() + 0.5f);
        mInitialTouchItemId = holder.getItemId();

        if (mInitiateOnLongPress) {
            mHandler.startLongPressDetection(e);
        }

        return true;
    }
 
开发者ID:pczhu,项目名称:android-advancedrecyclerview-master,代码行数:18,代码来源:RecyclerViewDragDropManager.java

示例7: RemovingItemDecorator

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
public RemovingItemDecorator(RecyclerView rv, RecyclerView.ViewHolder swipingItem, int result, long removeAnimationDuration, long moveAnimationDuration) {
    mRecyclerView = rv;
    mSwipingItem = swipingItem;
    mSwipingItemId = swipingItem.getItemId();
    mHorizontal = (result == RecyclerViewSwipeManager.RESULT_SWIPED_LEFT || result == RecyclerViewSwipeManager.RESULT_SWIPED_RIGHT);

    mRemoveAnimationDuration = removeAnimationDuration + ADDITIONAL_REMOVE_DURATION;
    mMoveAnimationDuration = moveAnimationDuration;
    mTranslationX = (int) (ViewCompat.getTranslationX(swipingItem.itemView) + 0.5f);
    mTranslationY = (int) (ViewCompat.getTranslationY(swipingItem.itemView) + 0.5f);

    CustomRecyclerViewUtils.getViewBounds(mSwipingItem.itemView, mSwipingItemBounds);
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:14,代码来源:RemovingItemDecorator.java

示例8: attachRecyclerView

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
/**
 * <p>Attaches {@link android.support.v7.widget.RecyclerView} instance.</p>
 * <p>Before calling this method, the target {@link android.support.v7.widget.RecyclerView} must set
 * the wrapped adapter instance which is returned by the
 * {@link #createWrappedAdapter(android.support.v7.widget.RecyclerView.Adapter)} method.</p>
 *
 * @param rv The {@link android.support.v7.widget.RecyclerView} instance
 */
public void attachRecyclerView(@NonNull RecyclerView rv) {
    if (rv == null) {
        throw new IllegalArgumentException("RecyclerView cannot be null");
    }

    if (isReleased()) {
        throw new IllegalStateException("Accessing released object");
    }

    if (mRecyclerView != null) {
        throw new IllegalStateException("RecyclerView instance has already been set");
    }

    if (mAdapter == null || getSwipeableItemWrapperAdapter(rv) != mAdapter) {
        throw new IllegalStateException("adapter is not set properly");
    }

    final int layoutOrientation = CustomRecyclerViewUtils.getOrientation(rv);
    if (layoutOrientation == CustomRecyclerViewUtils.ORIENTATION_UNKNOWN) {
        throw new IllegalStateException("failed to determine layout orientation");
    }

    mRecyclerView = rv;
    mRecyclerView.addOnItemTouchListener(mInternalUseOnItemTouchListener);

    final ViewConfiguration vc = ViewConfiguration.get(rv.getContext());

    mTouchSlop = vc.getScaledTouchSlop();
    mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
    mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity();

    mItemSlideAnimator = new ItemSlidingAnimator(mAdapter);
    mItemSlideAnimator.setImmediatelySetTranslationThreshold(
            (int) (rv.getResources().getDisplayMetrics().density * SLIDE_ITEM_IMMEDIATELY_SET_TRANSLATION_THRESHOLD_DP + 0.5f));

    mSwipeHorizontal = (layoutOrientation == CustomRecyclerViewUtils.ORIENTATION_VERTICAL);
    mHandler = new InternalHandler(this);
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:47,代码来源:RecyclerViewSwipeManager.java

示例9: checkConditionAndStartSwiping

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
private boolean checkConditionAndStartSwiping(MotionEvent e, RecyclerView.ViewHolder holder) {
    final int itemPosition = CustomRecyclerViewUtils.getSynchronizedPosition(holder);

    if (itemPosition == RecyclerView.NO_POSITION) {
        return false;
    }

    startSwiping(e, holder, itemPosition);

    return true;
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:12,代码来源:RecyclerViewSwipeManager.java

示例10: startSwiping

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
private void startSwiping(MotionEvent e, RecyclerView.ViewHolder holder, int itemPosition) {
    if (LOCAL_LOGD) {
        Log.d(TAG, "swiping started");
    }

    mHandler.cancelLongPressDetection();

    mSwipingItem = holder;
    mSwipingItemPosition = itemPosition;
    mSwipingItemId = mAdapter.getItemId(itemPosition);
    mLastTouchX = (int) (e.getX() + 0.5f);
    mLastTouchY = (int) (e.getY() + 0.5f);
    mTouchedItemOffsetX = mLastTouchX;
    mTouchedItemOffsetY = mLastTouchY;
    mCheckingTouchSlop = RecyclerView.NO_ID;
    CustomRecyclerViewUtils.getLayoutMargins(holder.itemView, mSwipingItemMargins);

    mSwipingItemOperator = new SwipingItemOperator(this, mSwipingItem, mSwipingItemReactionType, mSwipeHorizontal);
    mSwipingItemOperator.start();

    mVelocityTracker.clear();
    mVelocityTracker.addMovement(e);

    mRecyclerView.getParent().requestDisallowInterceptTouchEvent(true);

    // raise onItemSwipeStarted() event
    if (mItemSwipeEventListener != null) {
        mItemSwipeEventListener.onItemSwipeStarted(itemPosition);
    }

    // raise onSwipeItemStarted() event
    mAdapter.onSwipeItemStarted(this, holder, mSwipingItemId);
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:34,代码来源:RecyclerViewSwipeManager.java

示例11: DraggingItemInfo

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
public DraggingItemInfo(RecyclerView.ViewHolder vh, int touchX, int touchY) {
    width = vh.itemView.getWidth();
    height = vh.itemView.getHeight();
    id = vh.getItemId();
    grabbedPositionX = touchX - vh.itemView.getLeft();
    grabbedPositionY = touchY - vh.itemView.getTop();
    margins = new Rect();
    CustomRecyclerViewUtils.getLayoutMargins(vh.itemView, margins);
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:10,代码来源:DraggingItemInfo.java

示例12: SwapTargetItemOperator

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
public SwapTargetItemOperator(RecyclerView recyclerView, RecyclerView.ViewHolder draggingItem, ItemDraggableRange range, DraggingItemInfo draggingItemInfo) {
    super(recyclerView, draggingItem);

    mDraggingItemInfo = draggingItemInfo;
    mRange = range;

    CustomRecyclerViewUtils.getDecorationOffsets(
            mRecyclerView.getLayoutManager(), mDraggingItemViewHolder.itemView, mDraggingItemDecorationOffsets);
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:10,代码来源:SwapTargetItemOperator.java

示例13: updateSwapTargetTranslation

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
private void updateSwapTargetTranslation(RecyclerView.ViewHolder draggingItem, RecyclerView.ViewHolder swapTargetItem, float translationPhase) {
    final View swapItemView = swapTargetItem.itemView;

    final int pos1 = draggingItem.getLayoutPosition();
    final int pos2 = swapTargetItem.getLayoutPosition();

    final Rect m1 = mDraggingItemInfo.margins;
    final Rect d1 = mDraggingItemDecorationOffsets;
    final int h1 = mDraggingItemInfo.height + m1.top + m1.bottom + d1.top + d1.bottom;
    final int w1 = mDraggingItemInfo.width + m1.left + m1.right + d1.left + d1.right;

    if (mSwapTargetTranslationInterpolator != null) {
        translationPhase = mSwapTargetTranslationInterpolator.getInterpolation(translationPhase);
    }

    switch (CustomRecyclerViewUtils.getOrientation(mRecyclerView)) {
        case CustomRecyclerViewUtils.ORIENTATION_VERTICAL:
            if (pos1 > pos2) {
                // dragging item moving to upward
                ViewCompat.setTranslationY(swapItemView, translationPhase * h1);
            } else {
                // dragging item moving to downward
                ViewCompat.setTranslationY(swapItemView, (translationPhase - 1.0f) * h1);
            }
            break;
        case CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL:
            if (pos1 > pos2) {
                // dragging item moving to upward
                ViewCompat.setTranslationX(swapItemView, translationPhase * w1);
            } else {
                // dragging item moving to downward
                ViewCompat.setTranslationX(swapItemView, (translationPhase - 1.0f) * w1);
            }
            break;
    }
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:37,代码来源:SwapTargetItemOperator.java

示例14: handleScrollOnDragging

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
void handleScrollOnDragging() {
    final RecyclerView rv = mRecyclerView;

    switch (CustomRecyclerViewUtils.getOrientation(rv)) {
        case CustomRecyclerViewUtils.ORIENTATION_VERTICAL:
            handleScrollOnDraggingInternal(rv, false);
            break;
        case CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL:
            handleScrollOnDraggingInternal(rv, true);
            break;
    }
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:13,代码来源:RecyclerViewDragDropManager.java

示例15: handleActionDown

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入依赖的package包/类
private void handleActionDown(RecyclerView rv, MotionEvent e) {
    final RecyclerView.ViewHolder holder = CustomRecyclerViewUtils.findChildViewHolderUnderWithTranslation(rv, e.getX(), e.getY());

    mInitialTouchX = (int) (e.getX() + 0.5f);
    mInitialTouchY = (int) (e.getY() + 0.5f);

    if (holder instanceof ExpandableItemViewHolder) {
        mTouchedItemId = holder.getItemId();
    } else {
        mTouchedItemId = RecyclerView.NO_ID;
    }
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:13,代码来源:RecyclerViewExpandableItemManager.java


注:本文中的com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。