Пример #1
0
 @Override
 public void onViewCreated(View view, Bundle savedInstanceState) {
   super.onViewCreated(view, savedInstanceState);
   setupRvMovies();
   presenter = new TrendingShowsPresenterImpl(this);
   refreshLayout.setOnRefreshListener(
       () -> {
         refreshLayout.setRefreshing(true);
         presenter.downloadTrendingShows(FIRST_PAGE, MOVIE_LIMIT);
       });
   progressBar.setVisibility(View.VISIBLE);
   presenter.downloadTrendingShows(FIRST_PAGE, MOVIE_LIMIT);
 }
Пример #2
0
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
          super.onScrolled(recyclerView, dx, dy);
          int visibleItemCount = preloadLayoutManager.getChildCount();
          int totalItemCount = preloadLayoutManager.getItemCount();
          int firstVisibleItemPosition = preloadLayoutManager.findFirstVisibleItemPosition();

          if (!loading) {
            if ((visibleItemCount + firstVisibleItemPosition) >= totalItemCount
                && firstVisibleItemPosition >= 0
                && totalItemCount >= MOVIE_LIMIT) {
              loading = true;
              currentPageNumber = currentPageNumber + 1;
              presenter.downloadTrendingShows(currentPageNumber, MOVIE_LIMIT);
            }
          }
        }