Esempio n. 1
0
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {

          super.onScrolled(recyclerView, dx, dy);

          int visibleItemCount = mRecycler.getLayoutManager().getChildCount();
          int totalItemCount = mRecycler.getLayoutManager().getItemCount();
          int pastVisibleItems =
              ((GridLayoutManager) mRecycler.getLayoutManager()).findFirstVisibleItemPosition();

          if ((visibleItemCount + pastVisibleItems) >= totalItemCount
              && !MainActivity.mEventsPresenter.isLoading()) {
            MainActivity.mEventsPresenter.onEndListReached();
          }

          // Is scrolling up
          if (dy > 10) {

            if (!flag) {
              // showToolbar();
              flag = true;
            }

            // Is scrolling down
          } else if (dy < -10) {

            if (flag) {
              // hideToolbar();
              flag = false;
            }
          }
        }
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
          super.onScrolled(recyclerView, dx, dy);

          scrollXValue += dx;
          scrollYValue += dy;

          if (getActivity() instanceof HeaderViewProvider) {
            HeaderViewProvider headerViewProvider = (HeaderViewProvider) getActivity();

            if (scrollYValue < headerViewProvider.getHeaderViewHeight() + 400) {
              headerViewProvider.onHeadScrollHScrolled(scrollYValue);
            }
          }
        }