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