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


Java CustomRecyclerViewUtils.getSynchronizedPosition方法代码示例

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


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

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

示例2: handleActionDown

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

    if (!(holder instanceof SwipeableItemViewHolder)) {
        return false;
    }

    final int itemPosition = CustomRecyclerViewUtils.getSynchronizedPosition(holder);

    // verify the touched item is valid state
    if (!(itemPosition >= 0 && itemPosition < adapter.getItemCount())) {
        return false;
    }
    if (holder.getItemId() != adapter.getItemId(itemPosition)) {
        return false;
    }

    final int touchX = (int) (e.getX() + 0.5f);
    final int touchY = (int) (e.getY() + 0.5f);

    final View view = holder.itemView;
    final int translateX = (int) (ViewCompat.getTranslationX(view) + 0.5f);
    final int translateY = (int) (ViewCompat.getTranslationY(view) + 0.5f);
    final int viewX = touchX - (view.getLeft() + translateX);
    final int viewY = touchY - (view.getTop() + translateY);

    final int reactionType = mAdapter.getSwipeReactionType(holder, itemPosition, viewX, viewY);

    if (reactionType == 0) {
        return false;
    }

    mInitialTouchX = touchX;
    mInitialTouchY = touchY;
    mCheckingTouchSlop = holder.getItemId();
    mSwipingItemReactionType = reactionType;

    return true;
}
 
开发者ID:WriterOfAlicrow,项目名称:OpenCVTour,代码行数:41,代码来源:RecyclerViewSwipeManager.java

示例3: handleActionMoveWhileNotSwiping

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入方法依赖的package包/类
private boolean handleActionMoveWhileNotSwiping(RecyclerView rv, MotionEvent e) {
    if (mCheckingTouchSlop == RecyclerView.NO_ID) {
        return false;
    }

    if (Math.abs(e.getY() - mInitialTouchY) > mTouchSlop) {
        // scrolling occurred
        mCheckingTouchSlop = RecyclerView.NO_ID;
        return false;
    }

    if (Math.abs(e.getX() - mInitialTouchX) <= mTouchSlop) {
        return false;
    }

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

    if (holder == null || holder.getItemId() != mCheckingTouchSlop) {
        mCheckingTouchSlop = RecyclerView.NO_ID;
        return false;
    }

    final int itemPosition = CustomRecyclerViewUtils.getSynchronizedPosition(holder);

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

    if (LOCAL_LOGD) {
        Log.d(TAG, "swiping started");
    }

    startSwiping(rv, e, holder, itemPosition);

    return true;
}
 
开发者ID:WriterOfAlicrow,项目名称:OpenCVTour,代码行数:37,代码来源:RecyclerViewSwipeManager.java

示例4: handleActionDown

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

    if (!(holder instanceof SwipeableItemViewHolder)) {
        return false;
    }

    final int itemPosition = CustomRecyclerViewUtils.getSynchronizedPosition(holder);

    // verify the touched item is valid state
    if (!(itemPosition >= 0 && itemPosition < adapter.getItemCount())) {
        return false;
    }
    if (holder.getItemId() != adapter.getItemId(itemPosition)) {
        return false;
    }

    final int touchX = (int) (e.getX() + 0.5f);
    final int touchY = (int) (e.getY() + 0.5f);

    final View view = holder.itemView;
    final int translateX = (int) (ViewCompat.getTranslationX(view) + 0.5f);
    final int translateY = (int) (ViewCompat.getTranslationY(view) + 0.5f);
    final int viewX = touchX - (view.getLeft() + translateX);
    final int viewY = touchY - (view.getTop() + translateY);

    final int reactionType = mAdapter.getSwipeReactionType(holder, itemPosition, viewX, viewY);

    if (reactionType == 0) {
        return false;
    }

    mInitialTouchX = touchX;
    mInitialTouchY = touchY;
    mCheckingTouchSlop = holder.getItemId();
    mSwipingItemReactionType = reactionType;

    if ((reactionType & REACTION_START_SWIPE_ON_LONG_PRESS) != 0) {
        mHandler.startLongPressDetection(e, mLongPressTimeout);
    }

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

示例5: checkConditionAndStartDragging

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入方法依赖的package包/类
private boolean checkConditionAndStartDragging(RecyclerView rv, MotionEvent e, boolean checkTouchSlop) {
    if (mDraggingItemInfo != null) {
        return false;
    }

    final int touchX = (int) (e.getX() + 0.5f);
    final int touchY = (int) (e.getY() + 0.5f);

    mLastTouchX = touchX;
    mLastTouchY = touchY;

    if (mInitialTouchItemId == RecyclerView.NO_ID) {
        return false;
    }

    if (checkTouchSlop) {
        if (!((mCanDragH && (Math.abs(touchX - mInitialTouchX) > mTouchSlop)) ||
                (mCanDragV && (Math.abs(touchY - mInitialTouchY) > mTouchSlop)))) {
            return false;
        }
    }

    final RecyclerView.ViewHolder holder = CustomRecyclerViewUtils.findChildViewHolderUnderWithoutTranslation(rv, mInitialTouchX, mInitialTouchY);

    if (holder == null) {
        return false;
    }

    int position = CustomRecyclerViewUtils.getSynchronizedPosition(holder);

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

    final View view = holder.itemView;
    final int translateX = (int) (ViewCompat.getTranslationX(view) + 0.5f);
    final int translateY = (int) (ViewCompat.getTranslationY(view) + 0.5f);
    final int viewX = touchX - (view.getLeft() + translateX);
    final int viewY = touchY - (view.getTop() + translateY);

    if (!mAdapter.canStartDrag(holder, position, viewX, viewY)) {
        return false;
    }

    ItemDraggableRange range = mAdapter.getItemDraggableRange(holder, position);

    if (range == null) {
        range = new ItemDraggableRange(0, Math.max(0, mAdapter.getItemCount() - 1));
    }

    verifyItemDraggableRange(range, holder);


    if (LOCAL_LOGD) {
        Log.d(TAG, "dragging started");
    }

    startDragging(rv, e, holder, range);

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

示例6: handleActionUpOrCancel

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入方法依赖的package包/类
private boolean handleActionUpOrCancel(RecyclerView rv, MotionEvent e) {
    final long touchedItemId = mTouchedItemId;
    final int initialTouchX = mInitialTouchX;
    final int initialTouchY = mInitialTouchY;

    mTouchedItemId = RecyclerView.NO_ID;
    mInitialTouchX = 0;
    mInitialTouchY = 0;

    if (!((touchedItemId != RecyclerView.NO_ID) && (MotionEventCompat.getActionMasked(e) == MotionEvent.ACTION_UP))) {
        return false;
    }

    final int touchX = (int) (e.getX() + 0.5f);
    final int touchY = (int) (e.getY() + 0.5f);

    final int diffX = touchX - initialTouchX;
    final int diffY = touchY - initialTouchY;

    if (!((Math.abs(diffX) < mTouchSlop) && (Math.abs(diffY) < mTouchSlop))) {
        return false;
    }

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

    if (!((holder != null) && (holder.getItemId() == touchedItemId))) {
        return false;
    }

    final int position = CustomRecyclerViewUtils.getSynchronizedPosition(holder);

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

    final View view = holder.itemView;
    final int translateX = (int) (ViewCompat.getTranslationX(view) + 0.5f);
    final int translateY = (int) (ViewCompat.getTranslationY(view) + 0.5f);
    final int viewX = touchX - (view.getLeft() + translateX);
    final int viewY = touchY - (view.getTop() + translateY);

    return mAdapter.onTapItem(holder, position, viewX, viewY);
}
 
开发者ID:fabricethilaw,项目名称:expandable-recyclerview-with-gridlayout,代码行数:44,代码来源:RecyclerViewExpandableItemManager.java

示例7: checkConditionAndStartDragging

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入方法依赖的package包/类
private boolean checkConditionAndStartDragging(RecyclerView rv, MotionEvent e, boolean checkTouchSlop) {
    final int touchX = (int) (e.getX() + 0.5f);
    final int touchY = (int) (e.getY() + 0.5f);

    mLastTouchY = touchY;

    if (mInitialTouchItemId == RecyclerView.NO_ID) {
        return false;
    }

    if (checkTouchSlop) {
        if (!(Math.abs(touchY - mInitialTouchY) > mTouchSlop)) {
            return false;
        }
    }

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

    if (!checkTouchedItemState(rv, holder)) {
        mInitialTouchItemId = RecyclerView.NO_ID;
        return false;
    }

    if (holder.getItemId() != mInitialTouchItemId) {
        mInitialTouchItemId = RecyclerView.NO_ID;
        return false;
    }

    int position = CustomRecyclerViewUtils.getSynchronizedPosition(holder);

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

    final View view = holder.itemView;
    final int translateX = (int) (ViewCompat.getTranslationX(view) + 0.5f);
    final int translateY = (int) (ViewCompat.getTranslationY(view) + 0.5f);
    final int viewX = touchX - (view.getLeft() + translateX);
    final int viewY = touchY - (view.getTop() + translateY);

    if (!mAdapter.canStartDrag(holder, position, viewX, viewY)) {
        return false;
    }

    ItemDraggableRange range = mAdapter.getItemDraggableRange(holder, position);

    if (range == null) {
        range = new ItemDraggableRange(0, Math.max(0, mAdapter.getItemCount() - 1));
    }

    verifyItemDraggableRange(range, holder);


    if (LOCAL_LOGD) {
        Log.d(TAG, "dragging started");
    }

    startDragging(rv, e, holder, range);

    return true;
}
 
开发者ID:WriterOfAlicrow,项目名称:OpenCVTour,代码行数:62,代码来源:RecyclerViewDragDropManager.java

示例8: checkConditionAndStartDragging

import com.h6ah4i.android.widget.advrecyclerview.utils.CustomRecyclerViewUtils; //导入方法依赖的package包/类
private boolean checkConditionAndStartDragging(RecyclerView rv, MotionEvent e, boolean checkTouchSlop) {
    if (mDraggingItem != null) {
        return false;
    }

    final int touchX = (int) (e.getX() + 0.5f);
    final int touchY = (int) (e.getY() + 0.5f);

    mLastTouchY = touchY;

    if (mInitialTouchItemId == RecyclerView.NO_ID) {
        return false;
    }

    if (checkTouchSlop) {
        if (!(Math.abs(touchY - mInitialTouchY) > mTouchSlop)) {
            return false;
        }
    }

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

    if (!checkTouchedItemState(rv, holder) || holder.getItemId() != mInitialTouchItemId) {
        mInitialTouchItemId = RecyclerView.NO_ID;
        mHandler.cancelLongPressDetection();

        return false;
    }

    int position = CustomRecyclerViewUtils.getSynchronizedPosition(holder);

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

    final View view = holder.itemView;
    final int translateX = (int) (ViewCompat.getTranslationX(view) + 0.5f);
    final int translateY = (int) (ViewCompat.getTranslationY(view) + 0.5f);
    final int viewX = touchX - (view.getLeft() + translateX);
    final int viewY = touchY - (view.getTop() + translateY);

    if (!mAdapter.canStartDrag(holder, position, viewX, viewY)) {
        return false;
    }

    ItemDraggableRange range = mAdapter.getItemDraggableRange(holder, position);

    if (range == null) {
        range = new ItemDraggableRange(0, Math.max(0, mAdapter.getItemCount() - 1));
    }

    verifyItemDraggableRange(range, holder);


    if (LOCAL_LOGD) {
        Log.d(TAG, "dragging started");
    }

    startDragging(rv, e, holder, range);

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


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