Skip to content

Lazy loading

JingYeoh edited this page Dec 18, 2017 · 5 revisions

May be you found that ViewPager uses Preloading when you are using ViewPager+Fragment,But sometimes we don't need load before the Fragment is visible,so this library provides Lazy Loading.

Configuration

First: Add @LazyLoad in the Fragment need to uses lazy loading.This annotation can be extended,so if you don't want use lazy loading you can set this annotation's value false.
Second: Add a public method onLazyLoadViewCreated with one parameter Bundle.
Note: this method must be public and the name must be onLazyLoadViewCreated and have one parameter Bundle.

@Lazyload(true)
@Puppet
public class ContainerFragment extend Fragment{
  public void onLazyLoadViewCreated(Bundle savedInstanceState) {
   //do something in here
  }
}