예제 #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);
            }
          }
        }