本文整理匯總了Java中android.support.v7.widget.RecyclerView.getScrollState方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.getScrollState方法的具體用法?Java RecyclerView.getScrollState怎麽用?Java RecyclerView.getScrollState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.getScrollState方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: refresh
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void refresh(final boolean layoutUpdated) {
final RecyclerView contentView = getContentView();
if (contentView == null) return;
if (contentView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) {
// contentView.stopScroll();
}
updateRunnable = new Runnable() {
@Override
public void run() {
if (!contentView.isComputingLayout()) {
//to prevent notify update when recyclerView is in computingLayout process
mGroupBasicAdapter.notifyUpdate(layoutUpdated);
if (mSwipeItemTouchListener != null) {
mSwipeItemTouchListener.updateCurrCard();
}
}
}
};
contentView.post(updateRunnable);
}
示例2: onInterceptTouchEvent
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
if ((recyclerView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) ||
!isAttachedToWindow(recyclerView) || !hasAdapter(recyclerView)) {
return false;
}
if (findFixedChildViewUnder(motionEvent) != null) {
return false;
}
if (findScrollableChildViewUnder(motionEvent) != null) {
return false;
}
mSwipeGestureDector.onTouchEvent(motionEvent);
return isSwiping();
}
示例3: onScrolled
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@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));
}
}
}
示例4: onInterceptTouchEvent
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_DOWN) {
if (rv.getScrollState() == RecyclerView.SCROLL_STATE_IDLE) {
if (m_jLastTouchedRecyclerView != null && rv != m_jLastTouchedRecyclerView) {
removeLastTouchedRecyclerViewScrollListener(false);
}
m_nYPosition = ((CellRecyclerView) rv).getScrolledY();
rv.addOnScrollListener(this);
if (rv == m_jCellRecyclerView) {
Log.d(LOG_TAG, "m_jCellRecyclerView scroll listener added");
} else if (rv == m_jRowHeaderRecyclerView) {
Log.d(LOG_TAG, "m_jRowHeaderRecyclerView scroll listener added");
}
// Refresh the value;
m_bMoved = false;
}
} else if (e.getAction() == MotionEvent.ACTION_MOVE) {
// Why does it matter ?
// user scroll any recyclerView like brushing, at that time, ACTION_UP will be
// triggered
// before scrolling. So, we need to store whether it moved or not.
m_bMoved = true;
} else if (e.getAction() == MotionEvent.ACTION_UP) {
int nScrollY = ((CellRecyclerView) rv).getScrolledY();
// TODO: Even if moved value is true and it may not scroll. This should be fixed.
// TODO: The scenario is scroll lightly center RecyclerView vertically.
// TODO: Below if condition may be changed later.
// Is it just touched without scrolling then remove the listener
if (m_nYPosition == nScrollY && !m_bMoved && rv.getScrollState() == RecyclerView
.SCROLL_STATE_IDLE) {
rv.removeOnScrollListener(this);
if (rv == m_jCellRecyclerView) {
Log.d(LOG_TAG, "m_jCellRecyclerView scroll listener removed from up ");
} else if (rv == m_jRowHeaderRecyclerView) {
Log.d(LOG_TAG, "m_jRowHeaderRecyclerView scroll listener removed from up");
}
}
m_jLastTouchedRecyclerView = rv;
}
return false;
}