當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。