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


Java CustomRecyclerViewUtils.ORIENTATION_VERTICAL属性代码示例

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


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

示例1: handleActionDown

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,代码行数:26,代码来源:RecyclerViewDragDropManager.java

示例2: updateDragDirectionMask

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,代码行数:21,代码来源:RecyclerViewDragDropManager.java

示例3: attachRecyclerView

/**
 * <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,代码行数:46,代码来源:RecyclerViewSwipeManager.java

示例4: updateSwapTargetTranslation

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,代码行数:36,代码来源:SwapTargetItemOperator.java

示例5: handleScrollOnDragging

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,代码行数:12,代码来源:RecyclerViewDragDropManager.java

示例6: calculateTranslationPhase

private float calculateTranslationPhase(RecyclerView.ViewHolder draggingItem, RecyclerView.ViewHolder swapTargetItem) {
    final View swapItemView = swapTargetItem.itemView;

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

    CustomRecyclerViewUtils.getDecorationOffsets(
            mRecyclerView.getLayoutManager(), swapItemView, mSwapTargetDecorationOffsets);
    CustomRecyclerViewUtils.getLayoutMargins(swapItemView, mSwapTargetItemMargins);

    final Rect m2 = mSwapTargetItemMargins;
    final Rect d2 = mSwapTargetDecorationOffsets;
    final int h2 = swapItemView.getHeight() + m2.top + m2.bottom + d2.top + d2.bottom;
    final int w2 = swapItemView.getWidth() + m2.left + m2.right + d2.left + d2.right;

    final float offsetXPx = draggingItem.itemView.getLeft() - mTranslationX; // == -(ViewCompat.getTranslationY(draggingItem.itemView)
    final float phaseX = (w2 != 0) ? (offsetXPx / w2) : 0.0f;
    final float offsetYPx = draggingItem.itemView.getTop() - mTranslationY; // == -(ViewCompat.getTranslationY(draggingItem.itemView)
    final float phaseY = (h2 != 0) ? (offsetYPx / h2) : 0.0f;

    float translationPhase = 0.0f;

    if (CustomRecyclerViewUtils.getOrientation(mRecyclerView) == CustomRecyclerViewUtils.ORIENTATION_VERTICAL) {
        if (pos1 > pos2) {
            // dragging item moving to upward
            translationPhase = phaseY;
        } else {
            // dragging item moving to downward
            translationPhase = 1.0f + phaseY;
        }
    } else if (CustomRecyclerViewUtils.getOrientation(mRecyclerView) == CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL) {
        if (pos1 > pos2) {
            // dragging item moving to upward
            translationPhase = phaseX;
        } else {
            // dragging item moving to downward
            translationPhase = 1.0f + phaseX;
        }
    }


    return Math.min(Math.max(translationPhase, 0.0f), 1.0f);
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:43,代码来源:SwapTargetItemOperator.java

示例7: attachRecyclerView

/**
 * <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
 * @param scrollEventDistributor The distributor for {@link android.support.v7.widget.RecyclerView.OnScrollListener} event
 */
@Deprecated
public void attachRecyclerView(@NonNull RecyclerView rv, @Nullable @SuppressWarnings("deprecation") RecyclerViewOnScrollEventDistributor scrollEventDistributor) {
    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 || getDraggableItemWrapperAdapter(rv) != mAdapter) {
        throw new IllegalStateException("adapter is not set properly");
    }

    if (scrollEventDistributor != null) {
        final RecyclerView rv2 = scrollEventDistributor.getRecyclerView();

        if (rv2 != null && rv2 != rv) {
            throw new IllegalArgumentException("The scroll event distributor attached to different RecyclerView instance");
        }
    }

    mRecyclerView = rv;

    if (scrollEventDistributor != null) {
        scrollEventDistributor.add(mInternalUseOnScrollListener);
        mScrollEventRegisteredToDistributor = true;
    } else {
        mRecyclerView.addOnScrollListener(mInternalUseOnScrollListener);
        mScrollEventRegisteredToDistributor = false;
    }

    mRecyclerView.addOnItemTouchListener(mInternalUseOnItemTouchListener);

    mDisplayDensity = mRecyclerView.getResources().getDisplayMetrics().density;
    mTouchSlop = ViewConfiguration.get(mRecyclerView.getContext()).getScaledTouchSlop();
    mScrollTouchSlop = (int) (mTouchSlop * SCROLL_TOUCH_SLOP_MULTIPLY + 0.5f);
    mHandler = new InternalHandler(this);

    if (supportsEdgeEffect()) {
        // edge effect is available on ICS or later
        switch (CustomRecyclerViewUtils.getOrientation(mRecyclerView)) {
            case CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL:
                mEdgeEffectDecorator = new LeftRightEdgeEffectDecorator(mRecyclerView);
                break;
            case CustomRecyclerViewUtils.ORIENTATION_VERTICAL:
                mEdgeEffectDecorator = new TopBottomEdgeEffectDecorator(mRecyclerView);
                break;
        }
        if (mEdgeEffectDecorator != null) {
            mEdgeEffectDecorator.start();
        }
    }
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:67,代码来源:RecyclerViewDragDropManager.java

示例8: findSwapTargetItem

static RecyclerView.ViewHolder findSwapTargetItem(
        RecyclerView rv, RecyclerView.ViewHolder draggingItem,
        DraggingItemInfo draggingItemInfo, int overlayItemLeft, int overlayItemTop, ItemDraggableRange range) {
    RecyclerView.ViewHolder swapTargetHolder = null;

    if ((draggingItem == null) || (
            draggingItem.getAdapterPosition() != RecyclerView.NO_POSITION &&
                    draggingItem.getItemId() == draggingItemInfo.id)) {

        final int layoutType = CustomRecyclerViewUtils.getLayoutType(rv);
        final boolean isVerticalLayout =
                (CustomRecyclerViewUtils.extractOrientation(layoutType) == CustomRecyclerViewUtils.ORIENTATION_VERTICAL);

        if (isVerticalLayout) {
            overlayItemLeft = Math.max(overlayItemLeft, rv.getPaddingLeft());
            overlayItemLeft = Math.min(overlayItemLeft, Math.max(0, rv.getWidth() - rv.getPaddingRight() - draggingItemInfo.width));
        } else {
            overlayItemTop = Math.max(overlayItemTop, rv.getPaddingTop());
            overlayItemTop = Math.min(overlayItemTop, Math.max(0, rv.getHeight() - rv.getPaddingBottom() - draggingItemInfo.height));
        }

        switch (layoutType) {
            case CustomRecyclerViewUtils.LAYOUT_TYPE_GRID_HORIZONTAL:
            case CustomRecyclerViewUtils.LAYOUT_TYPE_GRID_VERTICAL:
                swapTargetHolder = findSwapTargetItemForGridLayoutManager(
                        rv, draggingItem, draggingItemInfo, overlayItemLeft, overlayItemTop, range, isVerticalLayout);
                break;
            case CustomRecyclerViewUtils.LAYOUT_TYPE_LINEAR_HORIZONTAL:
                swapTargetHolder = findSwapTargetItemForLinearLayoutManagerHorizontal(rv, draggingItem, draggingItemInfo, overlayItemLeft, overlayItemTop, range);
                break;
            case CustomRecyclerViewUtils.LAYOUT_TYPE_LINEAR_VERTICAL:
                swapTargetHolder = findSwapTargetItemForLinearLayoutManagerVertical(rv, draggingItem, draggingItemInfo, overlayItemLeft, overlayItemTop, range);
                break;
            default:
                break;
        }
    }

    // check range
    if (swapTargetHolder != null && range != null) {
        if (!range.checkInRange(swapTargetHolder.getAdapterPosition())) {
            swapTargetHolder = null;
        }
    }

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


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