本文整理汇总了Java中android.support.v7.widget.RecyclerView.NO_POSITION属性的典型用法代码示例。如果您正苦于以下问题:Java RecyclerView.NO_POSITION属性的具体用法?Java RecyclerView.NO_POSITION怎么用?Java RecyclerView.NO_POSITION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.NO_POSITION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: snapFromFling
/**
* Helper method to facilitate for snapping triggered by a fling.
*
* @param layoutManager The {@link RecyclerView.LayoutManager} associated with the attached
* {@link RecyclerView}.
* @param velocityX Fling velocity on the horizontal axis.
* @param velocityY Fling velocity on the vertical axis.
* @return true if it is handled, false otherwise.
*/
private boolean snapFromFling(@NonNull RecyclerView.LayoutManager layoutManager, int velocityX,
int velocityY) {
if (!(layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider)) {
return false;
}
RecyclerView.SmoothScroller smoothScroller = createSnapScroller(layoutManager);
if (smoothScroller == null) {
return false;
}
int targetPosition = findTargetSnapPosition(layoutManager, velocityX, velocityY);
if (targetPosition == RecyclerView.NO_POSITION) {
return false;
}
smoothScroller.setTargetPosition(targetPosition);
layoutManager.startSmoothScroll(smoothScroller);
return true;
}
示例2: onClick
@Override
public void onClick(View v) {
int position = getAdapterPosition();
if (position != RecyclerView.NO_POSITION) {
Intent intent = new Intent(v.getContext(), DisplayProductsDescActivity.class);
Bundle bundle = new Bundle();
intent.putExtra("name", items.get(position).getName());
intent.putExtra("price", items.get(position).getPrice());
intent.putExtra("image_link", items.get(position).getImageLink());
intent.putExtra("product_link", items.get(position).getProductLink());
intent.putExtra("description", items.get(position).getDescription());
ArrayList<ProductColor> productColorArrayList = new ArrayList<ProductColor>(items
.get(position).getProductColors());
if (!productColorArrayList.isEmpty()) {
intent.putParcelableArrayListExtra("product_colors", productColorArrayList);
}
v.getContext().startActivity(intent);
}
}
示例3: onClick
@Override
public void onClick(View view) {
final int position = getAdapterPosition();
if(position != RecyclerView.NO_POSITION) {
mListener.onItemClick(position);
}
}
示例4: getStartView
private View getStartView(RecyclerView.LayoutManager layoutManager,
OrientationHelper helper) {
if (layoutManager instanceof LinearLayoutManager) {
int firstChild = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
boolean isLastItem = ((LinearLayoutManager) layoutManager)
.findLastCompletelyVisibleItemPosition()
== layoutManager.getItemCount() - 1;
if (firstChild == RecyclerView.NO_POSITION || isLastItem) {
return null;
}
View child = layoutManager.findViewByPosition(firstChild);
if (helper.getDecoratedEnd(child) >= helper.getDecoratedMeasurement(child) / 2
&& helper.getDecoratedEnd(child) > 0) {
return child;
} else {
if (((LinearLayoutManager) layoutManager).findLastCompletelyVisibleItemPosition()
== layoutManager.getItemCount() - 1) {
return null;
} else {
return layoutManager.findViewByPosition(firstChild + 1);
}
}
}
return super.findSnapView(layoutManager);
}
示例5: onUserClick
@OnClick(R.id.iv_user_avatar)
public void onUserClick(){
if(getAdapterPosition() != RecyclerView.NO_POSITION){
ProfileActivity.show((Activity) context, ivUserAvatar, data.get(getAdapterPosition()).getOwner().getLogin(),
data.get(getAdapterPosition()).getOwner().getAvatarUrl());
}
}
示例6: addItem
private void addItem(View view) {
int position = mRecyclerView.getChildAdapterPosition(view);
if (position != RecyclerView.NO_POSITION) {
int color = generateColor();
mColors.add(position, color);
notifyItemInserted(position);
}
}
示例7: onLongClick
@Override
public boolean onLongClick(View v) {
if(mOnItemLongClickListener != null && getAdapterPosition() != RecyclerView.NO_POSITION){
return mOnItemLongClickListener.onItemLongClick(getAdapterPosition(), v);
}
return false;
}
示例8: getFixedScrollPosition
/**
* @param direction 滑动方向,正负同{@link #mScrollOffset}的增减
* @param fixValue 同向修正值
* @return
*/
public int getFixedScrollPosition(int direction, float fixValue) {
if (mCheckedChildSize) {
if (mScrollOffset % mChildSize[mOrientation] == 0) {
return RecyclerView.NO_POSITION;
}
float position = mScrollOffset * 1.0f / mChildSize[mOrientation];
return convert2AdapterPosition((int) (direction > 0 ? position + fixValue : position + (1 - fixValue)) - 1);
}
return RecyclerView.NO_POSITION;
}
示例9: onClick
@Override
public void onClick(View v) {
int position = recyclerView.getChildAdapterPosition(v);
if (position != RecyclerView.NO_POSITION) {
QariDownloadInfo info = shuyookhAdapter.getSheikhInfoForPosition(position);
if (info.downloadedSuras.size() != 114) {
download(qariItems.get(position));
}
}
}
示例10: onLayoutChildren
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
if (state.isPreLayout()) {
return;
}
if (state.getItemCount() == 0) {
removeAndRecycleAllViews(recycler);
setCurrentPosition(RecyclerView.NO_POSITION, false);
return;
}
if (mDecoratedChildWidth == null || mDecoratedChildHeight == null) {
View view = recycler.getViewForPosition(0);
addView(view);
measureChildWithMargins(view, 0, 0);
mDecoratedChildWidth = getDecoratedMeasuredWidth(view);
mDecoratedChildHeight = getDecoratedMeasuredHeight(view);
removeAndRecycleView(view, recycler);
}
if (mCurrentPosition == RecyclerView.NO_POSITION) {
setCurrentPosition(0, false);
}
if (mCurrentPosition >= state.getItemCount()) {
setCurrentPosition(state.getItemCount() - 1, false);
}
detachAndScrapAttachedViews(recycler);
fill(recycler, state);
}
示例11: findFirstVisibleItemPosition
private int findFirstVisibleItemPosition(RecyclerView recyclerView) {
final View child = findOneVisibleChild(0, mLayoutManager.getChildCount(), false, true);
return child == null ? RecyclerView.NO_POSITION : recyclerView.getChildAdapterPosition(child);
}
示例12: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
switch (newState) {
case RecyclerView.SCROLL_STATE_DRAGGING:
// distinct drag to improve accuracy, init mDraggingStart and mDraggingEnd here
mDragging = true;
final int[] range = AbstractLayoutManagerUtils.getVisibleRange(recyclerView);
mDraggingStart = range[0];
mDraggingEnd = range[1];
break;
case RecyclerView.SCROLL_STATE_SETTLING:
mDragging = false;
break;
case RecyclerView.SCROLL_STATE_IDLE:
mDragging = false;
// perform final update on the range we have ever visited
updateVisibleRange(recyclerView);
AbstractLogUtils.e(this, "==> visible range: [" + mDraggingStart + ", " + mDraggingEnd + "]");
MeasurableRecyclerViewHelper.notifyMeasurableViewHolderDataRangeChanged(recyclerView, mDraggingStart, mDraggingEnd);
// reset mDraggingStart and mDraggingEnd here
mDraggingStart = RecyclerView.NO_POSITION;
mDraggingEnd = RecyclerView.NO_POSITION;
final boolean rtl = AbstractUIUtils.isRightToLeft(getRef());
if (mRtl ^ rtl) {
/*
* [ANDROID-1778]
*
* immediately flush the statistics if user change between a ltr and rtl language
* on the fly; do the check in here for better performance
*/
final List<IMeasurableViewHolder> holders =
MeasurableRecyclerViewHelper.getViewHolders(recyclerView, IMeasurableViewHolder.class);
for (IMeasurableViewHolder holder : holders) {
holder.flush();
}
if (AbstractLayoutManagerUtils.getOrientation(recyclerView.getLayoutManager())
== OrientationHelper.HORIZONTAL) {
AbstractLayoutManagerUtils.setReverseLayout(recyclerView.getLayoutManager(), mRtl);
}
}
break;
default:
break;
}
}
示例13: findLastContentItem
private ViewHolder findLastContentItem() {
int position = getNewTabPageAdapter().getLastContentItemPosition();
if (position == RecyclerView.NO_POSITION) return null;
return findViewHolderForAdapterPosition(position);
}
示例14: findFirstVisibleItemPosition
/**
* @return first visible item position.
*/
public int findFirstVisibleItemPosition() {
return getChildCount() != 0 ? getPosition(getChildAt(0)) : RecyclerView.NO_POSITION;
}
示例15: deleteItem
public void deleteItem(int position) {
if (position != RecyclerView.NO_POSITION) {
m_jItemList.remove(position);
notifyItemRemoved(position);
}
}