本文整理匯總了Java中android.support.v7.widget.RecyclerView.OnScrollListener方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.OnScrollListener方法的具體用法?Java RecyclerView.OnScrollListener怎麽用?Java RecyclerView.OnScrollListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.OnScrollListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setDefaultScrollListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected void setDefaultScrollListener() {
mRecyclerView.removeOnScrollListener(mOnScrollListener);
mOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (mHeader != null) {
mTotalYScrolled += dy;
if (isParallaxHeader)
translateHeader(mTotalYScrolled);
}
scroll_load_more_detection(recyclerView);
enableShoworHideToolbarAndFloatingButton(recyclerView);
}
};
mRecyclerView.addOnScrollListener(mOnScrollListener);
}
示例2: AutoLoadingAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
protected AutoLoadingAdapter(ItemClickListener clickListener) {
this.clickListener = clickListener;
data = new ArrayList<>();
visibleThreshold = 3;
scrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
final LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
int lastVisible = layoutManager.findLastVisibleItemPosition();
if (autoLoadEnabled && !isLoading && data.size() <= (lastVisible + visibleThreshold)) {
triggerLoading();
}
} else {
throw new UnsupportedOperationException("Can only be used with LinearLayoutManager");
}
}
};
}
示例3: getOnBottomListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
RecyclerView.OnScrollListener getOnBottomListener(LinearLayoutManager layoutManager) {
return new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView rv, int dx, int dy) {
int lastItemPosition, firstItemPosition, itemCount;
itemCount = mAdapter.getItemCount();
lastItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
firstItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
if (lastItemPosition == itemCount - 1 && lastItemPosition - firstItemPosition > 0) {
mPresenter.requestData(HomePresenter.REQUEST_LOAD_MORE);
} else if (firstItemPosition == 0) {
isTransparent(true);
} else {
isTransparent(false);
}
}
};
}
示例4: getOnBottomListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private RecyclerView.OnScrollListener getOnBottomListener(GridLayoutManager layoutManager) {
return new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
bottomListener(layoutManager);
}
};
}
示例5: setObserableScrollListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void setObserableScrollListener() {
mRecyclerView.removeOnScrollListener(mOnScrollListener);
mOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
enableShoworHideToolbarAndFloatingButton(recyclerView);
}
};
mRecyclerView.addOnScrollListener(mOnScrollListener);
}
示例6: setRecyclerViewScrollListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void setRecyclerViewScrollListener() {
layoutManagerType = null;
final RecyclerView recyclerView = (RecyclerView) child;
if (recyclerView.getAdapter() == null) {
return;
}
if (!(recyclerView.getAdapter() instanceof BaseRecyclerAdapter)) {
// throw new RuntimeException("Recylerview的adapter請繼承 BaseRecyclerAdapter");
LogUtils.w(RECYCLERVIEW_ADAPTER_WARIN);
return;
}
final BaseRecyclerAdapter adapter = (BaseRecyclerAdapter) recyclerView.getAdapter();
adapter.insideEnableFooter(mParent.getPullLoadEnable());
recyclerView.removeOnScrollListener(mOnScrollListener);
mOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (mRecyclerViewScrollListener != null) {
mRecyclerViewScrollListener.onScrollStateChanged(recyclerView, newState);
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
onRecyclerViewScrolled(recyclerView, adapter, dx, dy, false);
}
};
recyclerView.addOnScrollListener(mOnScrollListener);
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager != null && layoutManager instanceof GridLayoutManager) {
GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
gridLayoutManager.setSpanSizeLookup(new XSpanSizeLookup(adapter, gridLayoutManager.getSpanCount()));
}
initFooterCallBack(adapter, mParent);
}
示例7: getScrollListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public RecyclerView.OnScrollListener getScrollListener() {
return scrollListener;
}
示例8: initRecyclerView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Initialize the inner RecyclerView
*/
protected void initRecyclerView() {
if (mRecyclerView != null) {
mInternalOnScrollListener = new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (recyclerView.getLayoutManager().getClass().equals(LinearLayoutManager.class)) {
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
if (layoutManager.findLastVisibleItemPosition() >= layoutManager.getItemCount() - ITEM_LEFT_TO_LOAD_MORE
&& !isLoadingMore && shouldLoadMore) {
isLoadingMore = true;
if (mOnMoreListener != null) {
mOnMoreListener.onMoreAsked(mRecyclerView.getAdapter().getItemCount(), ITEM_LEFT_TO_LOAD_MORE, layoutManager.findLastVisibleItemPosition());
}
}
}
for (RecyclerView.OnScrollListener listener : mExternalOnScrollListeners)
listener.onScrolled(recyclerView, dx, dy);
}
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
for (RecyclerView.OnScrollListener listener : mExternalOnScrollListeners)
listener.onScrollStateChanged(recyclerView, newState);
}
};
mRecyclerView.addOnScrollListener(mInternalOnScrollListener);
}
//by default, empty screen is hidden and loading screen is displayed
if (mEmptyView != null)
mEmptyView.setVisibility(View.GONE);
if (mLoadingView != null)
mLoadingView.setVisibility(View.VISIBLE);
}
示例9: getScrollListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* @return ScrollListener which should be set as {@link RecyclerView}'s scroll listener
*/
public RecyclerView.OnScrollListener getScrollListener() {
return infiniteScrollListener;
}
示例10: addOnScrollListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addOnScrollListener(RecyclerView.OnScrollListener customOnScrollListener) {
mRecyclerView.addOnScrollListener(customOnScrollListener);
}
示例11: setOnScrollListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void setOnScrollListener(RecyclerView.OnScrollListener onScrollListener) {
this.onScrollListener = onScrollListener;
}
示例12: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_movies_list);
if (savedInstanceState != null) {
mMovies = savedInstanceState.getParcelableArrayList(STATE_LIST);
mFromSavedState = savedInstanceState.getBoolean(STATE_SPINNER);
mSortOrder = savedInstanceState.getString(STATE_SORT_ORDER);
sCurrentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE);
sTotalPages = savedInstanceState.getInt(STATE_TOTAL_PAGES);
mLoadMore = true;
}
mCompositeDisposable = new CompositeDisposable();
ButterKnife.bind(this);
mGridLayoutManager = new GridLayoutManager(this, 2);
mGridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
if (mAdapter.getItemViewType(position) == MoviesAdapter.ITEM_TYPE_LOADING) {
return 2;
}
return 1;
}
});
mMoviesList.setLayoutManager(mGridLayoutManager);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.sort_options, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSortSpinner.setAdapter(adapter);
mAdapter = new MoviesAdapter(mMovies, this);
mMoviesList.setAdapter(mAdapter);
RecyclerView.OnScrollListener recyclerViewScroll = new OnInfiniteScrollListener(this, mGridLayoutManager);
mMoviesList.addOnScrollListener(recyclerViewScroll);
if (mMovies.size() > 0) {
showList();
}
}
示例13: setOnScrollListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void setOnScrollListener(RecyclerView.OnScrollListener l) {
mScrollListener = l;
}
示例14: addOnScrollListener
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addOnScrollListener(RecyclerView.OnScrollListener onScrollListener) {
mInnerScrollListener = onScrollListener;
}
示例15: getmExternalOnScrollListeners
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* @return the scroll listeners of the recyclerView
*/
public List<RecyclerView.OnScrollListener> getmExternalOnScrollListeners() {
return mExternalOnScrollListeners;
}