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


Java ViewHolder.getAdapterPosition方法代碼示例

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


在下文中一共展示了ViewHolder.getAdapterPosition方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: moveIfNecessary

import android.support.v7.widget.RecyclerView.ViewHolder; //導入方法依賴的package包/類
private void moveIfNecessary(ViewHolder viewHolder) {
    if (!this.mRecyclerView.isLayoutRequested() && this.mActionState == 2) {
        float threshold = this.mCallback.getMoveThreshold(viewHolder);
        int x = (int) (this.mSelectedStartX + this.mDx);
        int y = (int) (this.mSelectedStartY + this.mDy);
        if (((float) Math.abs(y - viewHolder.itemView.getTop())) >= ((float) viewHolder.itemView.getHeight()) * threshold || ((float) Math.abs(x - viewHolder.itemView.getLeft())) >= ((float) viewHolder.itemView.getWidth()) * threshold) {
            List<ViewHolder> swapTargets = findSwapTargets(viewHolder);
            if (swapTargets.size() != 0) {
                ViewHolder target = this.mCallback.chooseDropTarget(viewHolder, swapTargets, x, y);
                if (target == null) {
                    this.mSwapTargets.clear();
                    this.mDistances.clear();
                    return;
                }
                int toPosition = target.getAdapterPosition();
                int fromPosition = viewHolder.getAdapterPosition();
                if (this.mCallback.onMove(this.mRecyclerView, viewHolder, target)) {
                    this.mCallback.onMoved(this.mRecyclerView, viewHolder, fromPosition, target, toPosition, x, y);
                }
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:24,代碼來源:ItemTouchHelper.java

示例2: clearView

import android.support.v7.widget.RecyclerView.ViewHolder; //導入方法依賴的package包/類
@Override
public void clearView(RecyclerView recyclerView, ViewHolder viewHolder) {
    // clearView() is called when an interaction with the item is finished, which does
    // not mean that the user went all the way and dismissed the item before releasing it.
    // We need to check that the item has been removed.
    if (viewHolder.getAdapterPosition() == RecyclerView.NO_POSITION) {
        mRecyclerView.onItemDismissFinished(viewHolder);
    }

    super.clearView(recyclerView, viewHolder);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:12,代碼來源:NewTabPageAdapter.java

示例3: getDismissSibling

import android.support.v7.widget.RecyclerView.ViewHolder; //導入方法依賴的package包/類
/**
 * Returns another view holder that should be dismissed at the same time as the provided one.
 */
public ViewHolder getDismissSibling(ViewHolder viewHolder) {
    int swipePos = viewHolder.getAdapterPosition();
    int siblingPosDelta = mRoot.getDismissSiblingPosDelta(swipePos);
    if (siblingPosDelta == 0) return null;

    return mRecyclerView.findViewHolderForAdapterPosition(siblingPosDelta + swipePos);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:11,代碼來源:NewTabPageAdapter.java

示例4: onMove

import android.support.v7.widget.RecyclerView.ViewHolder; //導入方法依賴的package包/類
/**
 * If this method returns true, ItemTouchHelper assumes viewHolder has been
 * moved to the adapter position of target ViewHolder
 * @param recyclerView
 * @param viewHolder
 * @param target
 * @return
 */
@Override
public boolean onMove(RecyclerView recyclerView,
                      ViewHolder viewHolder,
                      ViewHolder target) {
    int toPosition = target.getAdapterPosition();
    mListener.onItemMove(viewHolder.getAdapterPosition(), toPosition);

    draggedTo = toPosition;

    return true;
}
 
開發者ID:kiwiandroiddev,項目名稱:starcraft-2-build-player,代碼行數:20,代碼來源:SimpleItemTouchCallback.java

示例5: onMove

import android.support.v7.widget.RecyclerView.ViewHolder; //導入方法依賴的package包/類
@Override
public boolean onMove(RecyclerView recyclerView, ViewHolder viewHolder, ViewHolder target) {
    if (mDragCallback != null) {
        if (!mDragCallback.canDragDirs(recyclerView, target)) {
            return false;
        }

        int from = viewHolder.getAdapterPosition();
        int to = target.getAdapterPosition();

        mDragCallback.onMove(recyclerView, from, to);
        return true;
    }
    return false;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:16,代碼來源:RDragCallback.java

示例6: onChildDrawOver

import android.support.v7.widget.RecyclerView.ViewHolder; //導入方法依賴的package包/類
@Override
    public void onChildDrawOver(Canvas c, RecyclerView recyclerView, ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
        super.onChildDrawOver(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
//        L.e("call: onChildDrawOver([c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive])-> " + actionState + " " + isCurrentlyActive + " " + viewHolder, 300);
        if (drawOverInFullscreen && viewHolder.getAdapterPosition() >= 0) {
            //L.e("call: onChildDrawOver([c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive])-> dx:" + dX + " dy:" + dY + " " + actionState + " " + isCurrentlyActive);
            c.save();
            c.getClipBounds(clipBounds);
            clipBounds.inset(-ScreenUtil.screenWidth, -ScreenUtil.screenHeight);
            c.clipRect(clipBounds, Region.Op.REPLACE);
            c.translate(viewHolder.itemView.getLeft() + dX, viewHolder.itemView.getTop() + dY);
            viewHolder.itemView.draw(c);
            c.restore();
        }
    }
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:16,代碼來源:RDragCallback.java

示例7: getPosition

import android.support.v7.widget.RecyclerView.ViewHolder; //導入方法依賴的package包/類
public final int getPosition(@NonNull final ViewHolder holder) {
    return holder.getAdapterPosition();
}
 
開發者ID:free46000,項目名稱:MultiItem,代碼行數:4,代碼來源:ViewHolderManager.java


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