I have 2 requests one last for 5 seconds, another 10 seconds.

ViewPager creates 2 fragments at once, and therefore 2 requests occur immediately. As a result, to see 1 fragment you have to wait 10-20 seconds. It is not right. Yes, and you need to save traffic ... And why should I make a thousand requests if I want to see only one window

Creating a separate fragment without a ViewPager will not work, as the whole animation of the viewPager is needed.

the minimum fragment that the ViewPager creates is equal to 1 on the sides.

In the end, I'm in a bind.

I need to use the ViewPager to make requests only when the fragment is active without affecting the side fragments.

I don’t know it correctly or not, but it’s done in the VC application

    1 answer 1

    Make in fragments a check on visibility, when the user enters the fragment there will be a call

    @Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); } 

    c isVisibleToUser == true, then you can make a request.

    But the ViewPager doesn’t just create 2 fragments; it’s necessary that the user just doesn’t wait for the download to constantly switch.