Esempio n. 1
0
 @Override
 public void onViewCreated(View view, Bundle savedInstanceState) {
   super.onViewCreated(view, savedInstanceState);
   setupViewPager(viewPager);
   tabLayout.setupWithViewPager(viewPager);
   updateToolbar();
 }
 @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);
 }
        @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);
            }
          }
        }
 @Override
 public void onResume() {
   super.onResume();
   currentPageNumber = FIRST_PAGE;
 }
 @Override
 public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
   super.onScrollStateChanged(recyclerView, newState);
 }