本文整理匯總了Java中android.support.v7.widget.RecyclerView.SCROLL_STATE_IDLE屬性的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.SCROLL_STATE_IDLE屬性的具體用法?Java RecyclerView.SCROLL_STATE_IDLE怎麽用?Java RecyclerView.SCROLL_STATE_IDLE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.SCROLL_STATE_IDLE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
currentScrollState = newState;
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();
if (visibleItemCount != 0) {
int bottomOffset = (totalItemCount - lastVisibleItemPosition - 1) * (recyclerView.getHeight()) / visibleItemCount;
if (visibleItemCount > 0 && currentScrollState == RecyclerView.SCROLL_STATE_IDLE) {
if (listener != null && listener.get() != null) {
listener.get().onLoadMore(bottomOffset);
}
}
}
}
示例2: longPressAction
protected void longPressAction(MotionEvent e) {
// Consume the action for the time when the recyclerView is scrolling.
if (m_jRecyclerView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) {
return;
}
// Get interacted view from x,y coordinate.
View child = m_jRecyclerView.findChildViewUnder(e.getX(), e.getY());
if (child != null && getTableViewListener() != null) {
// Find the view holder
RecyclerView.ViewHolder holder = m_jRecyclerView.getChildViewHolder(child);
// Call ITableView listener for long click
getTableViewListener().onRowHeaderLongPressed(holder, holder.getAdapterPosition());
}
}
示例3: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (move && newState == RecyclerView.SCROLL_STATE_IDLE) {
move = false;
int n = mIndex - linearLayoutManager.findFirstVisibleItemPosition();
if (0 <= n && n < lyricListView.getChildCount()) {
int top = lyricListView.getChildAt(n).getTop();
lyricListView.smoothScrollBy(0, top);
}
}
}
示例4: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_SETTLING) {
mSnapping = false;
}
if (newState == RecyclerView.SCROLL_STATE_IDLE && mSnapping && mSnapListener != null) {
int position = getSnappedPosition(recyclerView);
if (position != RecyclerView.NO_POSITION) {
mSnapListener.onSnap(position);
}
mSnapping = false;
}
}
示例5: shouldStopScroll
/**
* Returns whether this {@link MotionEvent} should trigger the scroll to be stopped.
*/
protected boolean shouldStopScroll(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
if ((Math.abs(mDy) < mDeltaThreshold &&
getScrollState() != RecyclerView.SCROLL_STATE_IDLE)) {
// now the touch events are being passed to the {@link WidgetCell} until the
// touch sequence goes over the touch slop.
return true;
}
}
return false;
}
示例6: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (RecyclerView.SCROLL_STATE_IDLE == newState
&& recyclerView != null
&& lastMotionEvent != null) {
updateCurrCard();
}
}
示例7: onScrollStateChanged
@Override
public void onScrollStateChanged(int state) {
super.onScrollStateChanged(state);
if (state == RecyclerView.SCROLL_STATE_IDLE && mLoadingListener != null && !isLoadingData && loadingMoreEnabled) {
LayoutManager layoutManager = getLayoutManager();
int lastVisibleItemPosition;
if (layoutManager instanceof GridLayoutManager) {
lastVisibleItemPosition = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
int[] into = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()];
((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions(into);
lastVisibleItemPosition = findMax(into);
} else {
lastVisibleItemPosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
}
if (layoutManager.getChildCount() > 0
&& lastVisibleItemPosition >= layoutManager.getItemCount() - 1 && layoutManager.getItemCount() > layoutManager.getChildCount() && !isnomore && mRefreshHeader.getState() < YunRefreshHeader.STATE_REFRESHING) {
View footView = mFootViews.get(0);
isLoadingData = true;
if (footView instanceof LoadingMoreFooter) {
((LoadingMoreFooter) footView).setState(LoadingMoreFooter.STATE_LOADING);
} else {
footView.setVisibility(View.VISIBLE);
}
if (isNetWorkConnected(getContext())) {
mLoadingListener.onLoadMore();
} else {
postDelayed(new Runnable() {
@Override
public void run() {
mLoadingListener.onLoadMore();
}
}, 1000);
}
}
}
}
示例8: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
scrollState = newState;
L.w("scroll state : " + newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
onScrollEnd();
} else if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
isFling = false;
} else if (newState == RecyclerView.SCROLL_STATE_SETTLING) {
}
}
示例9: onLongPress
@Override
public void onLongPress(MotionEvent e) {
if (mPressedView != null) {
if (mRecyclerView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) {
return;
}
mPressedView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
BaseWrappedViewHolder baseWrappedViewHolder = (BaseWrappedViewHolder) mRecyclerView.getChildViewHolder(mPressedView);
if (baseWrappedViewHolder != null) {
boolean isLongClickConsume = false;
if (isHeaderViewOrFooterView(baseWrappedViewHolder.getItemViewType())) {
isLongClickConsume = true;
}
Set<Integer> ids = baseWrappedViewHolder.getLongClickableItemIds();
Set<Integer> nestIds = baseWrappedViewHolder.getNestIds();
if (ids != null && ids.size() > 0) {
for (Integer id :
ids) {
final View childView = mPressedView.findViewById(id);
if (childView != null) {
// 判斷點擊位置是否在該view上和該view是否可點擊
if (isOnRange(e, childView) && childView.isEnabled()) {
// 這裏要排除掉嵌套的recyclerView的點擊事件
if (nestIds != null && nestIds.contains(id)) {
break;
}
// 設置item的熱點
setChildHotSpot(childView, e);
childView.setPressed(true);
// 點擊接口
onItemChildLongClick(baseWrappedViewHolder, id, childView, baseWrappedViewHolder.getAdapterPosition() - mBaseWrappedAdapter.getHeaderViewCount());
// 恢複效果,提交,防止堵塞
isLongClickConsume = true;
isPressing = true;
break;
}
}
}
}
if (!isLongClickConsume) {
setChildHotSpot(mPressedView, e);
mPressedView.setPressed(true);
onItemLongClick(baseWrappedViewHolder, mPressedView, baseWrappedViewHolder.getAdapterPosition() - mBaseWrappedAdapter.getHeaderViewCount());
isPressing = true;
}
}
}
}
示例10: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (madapter != null && newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItem + 1 == madapter.getItemCount()) {
loadMoreData();
}
}
示例11: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
int visibleItemCount = layoutManager.getChildCount();
boolean triggerCondition = visibleItemCount > 0
&& newState == RecyclerView.SCROLL_STATE_IDLE
&& canTriggerLoadMore(recyclerView);
if (triggerCondition) {
onLoadMore(recyclerView);
}
}
示例12: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
conversationDateHeader.show();
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
conversationDateHeader.hide();
}
}
示例13: onScrollStateChanged
@Override
public void onScrollStateChanged(int state) {
super.onScrollStateChanged(state);
currentScrollState = state;
if (mLScrollListener != null) {
mLScrollListener.onScrollStateChanged(state);
}
if (mLoadMoreListener != null && mLoadMoreEnabled) {
if (currentScrollState == RecyclerView.SCROLL_STATE_IDLE || currentScrollState == RecyclerView.SCROLL_STATE_SETTLING) {
RecyclerView.LayoutManager layoutManager = getLayoutManager();
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();
if (visibleItemCount > 0
&& lastVisibleItemPosition >= totalItemCount - 1
&& totalItemCount > visibleItemCount
&& !isNoMore
&& !mRefreshing ) {
mFootView.setVisibility(View.VISIBLE);
if (mLoadingData) {
return;
} else {
mLoadingData = true;
mLoadMoreFooter.onLoading();
mLoadMoreListener.onLoadMore();
}
}
}
}
}
示例14: onScrolled
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
Adapter adapter = getAdapterRaw();
if (adapter != null && adapter instanceof RBaseAdapter) {
((RBaseAdapter) adapter).onScrolled(RRecyclerView.this, dx, dy);
if (recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE) {
//滾動結束
((RBaseAdapter) adapter).onScrollStateEnd(RRecyclerView.this,
isFirstItemVisible(), isLastItemVisible(),
UI.canChildScrollUp(recyclerView), UI.canChildScrollDown(recyclerView));
}
}
}
示例15: onScrollStateChanged
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (swallowNextScroll) {
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
swallowNextScroll = false;
}
return;
}
if ((newState == RecyclerView.SCROLL_STATE_IDLE || newState == RecyclerView.SCROLL_STATE_SETTLING)) {
tryLoadingMore();
}
}