Android Async task in viewpager -


i using fragmentstatepageradapter set viewpager content. in getitem() method of adapter, invoke fragment. want display product images , names dynamically server on each view pager fragment. calling async task in oncreateview() of fragment. async task adjacent products invoked. want know best way ?

should perform async task ahead , set adapter of view pager? if so, have 1000s of products, take huge time set adapter.

or should perform async task after every page has loaded? here, every time come page, keeps loading data server. want data loaded first time visit page, on next swipe, should display instead of fetchng server again.

i infinite view pager adapter, how possible ?

many in advance :)

... want data loaded first time visit page, on next swipe, should display instead of fetchng server again.

move asynctask call oncreateview setuservisiblehint: executed when fragment visible user:

@override public void setuservisiblehint(boolean isvisibletouser) {     super.setuservisiblehint(isvisibletouser);      if (isvisibletouser) {          // launch asynctask here, if task has not been executed yet         if(atask.getstatus().equals(asynctask.status.pending)) {             atask.execute();         }     } } 

... infinite view pager adapter, how possible ?

this has been answered, i.e.:

  1. viewpager circular queue / wrapping
  2. how create circular viewpager?

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -