當前位置: 首頁>>代碼示例>>Java>>正文


Java RecyclerView.OnScrollListener方法代碼示例

本文整理匯總了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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:UltimateRecyclerView.java

示例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");
            }
        }

    };
}
 
開發者ID:sztomek,項目名稱:cleanarchitecture-unidirectional,代碼行數:22,代碼來源:AutoLoadingAdapter.java

示例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);
            }
        }
    };
}
 
開發者ID:Shuanghua,項目名稱:LikeGank,代碼行數:19,代碼來源:MainActivity.java

示例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);
        }
    };
}
 
開發者ID:Shuanghua,項目名稱:LikeGank,代碼行數:10,代碼來源:ImageActivity.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:UltimateRecyclerView.java

示例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);
    }
 
開發者ID:LonelyMushroom,項目名稱:aarLibrary,代碼行數:39,代碼來源:XRefreshContentView.java

示例7: getScrollListener

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public RecyclerView.OnScrollListener getScrollListener() {
    return scrollListener;
}
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:4,代碼來源:DragSortRecycler.java

示例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);

}
 
開發者ID:LApptelier,項目名稱:SmartRecyclerView,代碼行數:47,代碼來源:SmartRecyclerView.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:InfiniteLoadingHelper.java

示例10: addOnScrollListener

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addOnScrollListener(RecyclerView.OnScrollListener customOnScrollListener) {
    mRecyclerView.addOnScrollListener(customOnScrollListener);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:UltimateRecyclerView.java

示例11: setOnScrollListener

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void setOnScrollListener(RecyclerView.OnScrollListener onScrollListener) {
    this.onScrollListener = onScrollListener;
}
 
開發者ID:zhouchaoyuan,項目名稱:excelPanel,代碼行數:4,代碼來源:MajorRecyclerViewAdapter.java

示例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();
    }
}
 
開發者ID:dilipkumar4813,項目名稱:movie-android,代碼行數:45,代碼來源:MoviesListActivity.java

示例13: setOnScrollListener

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void setOnScrollListener(RecyclerView.OnScrollListener l) {
    mScrollListener = l;
}
 
開發者ID:bigjelly,項目名稱:ShaddockVideoPlayer,代碼行數:4,代碼來源:PullRecyclerView.java

示例14: addOnScrollListener

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public void addOnScrollListener(RecyclerView.OnScrollListener onScrollListener) {
        mInnerScrollListener = onScrollListener;
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:4,代碼來源:MultiFuncRecyclerView.java

示例15: getmExternalOnScrollListeners

import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
 * @return the scroll listeners of the recyclerView
 */
public List<RecyclerView.OnScrollListener> getmExternalOnScrollListeners() {
    return mExternalOnScrollListeners;
}
 
開發者ID:LApptelier,項目名稱:SmartRecyclerView,代碼行數:7,代碼來源:SmartRecyclerView.java


注:本文中的android.support.v7.widget.RecyclerView.OnScrollListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。