本文整理匯總了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);
}
}
}
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
}
示例7: getPosition
import android.support.v7.widget.RecyclerView.ViewHolder; //導入方法依賴的package包/類
public final int getPosition(@NonNull final ViewHolder holder) {
return holder.getAdapterPosition();
}