當前位置: 首頁>>代碼示例>>Java>>正文


Java CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL屬性代碼示例

本文整理匯總了Java中com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL屬性的典型用法代碼示例。如果您正苦於以下問題:Java CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL屬性的具體用法?Java CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL怎麽用?Java CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils的用法示例。


在下文中一共展示了CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例4: 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

示例5: 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

示例6: 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


注:本文中的com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils.ORIENTATION_HORIZONTAL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。