@Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mUris =
        new Uri[] {
          sampleUris().createSampleUri(ImageSize.L, Orientation.LANDSCAPE),
          sampleUris().createSampleUri(ImageSize.L, Orientation.PORTRAIT),
        };

    final Button clearCacheButton = (Button) view.findViewById(R.id.clear_cache);
    clearCacheButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            for (Uri uri : mUris) {
              Fresco.getImagePipeline().evictFromCache(uri);
            }
          }
        });

    mPrefetchStatus = (TextView) view.findViewById(R.id.prefetch_status);
    mPrefetchDiskButton = (Button) view.findViewById(R.id.prefetch_disk_now);
    mPrefetchDiskButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPrefetchDiskButton.setEnabled(false);
            final PrefetchSubscriber subscriber = new PrefetchSubscriber();
            for (Uri uri : mUris) {
              final DataSource<Void> ds =
                  Fresco.getImagePipeline().prefetchToDiskCache(ImageRequest.fromUri(uri), null);
              ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
            }
          }
        });

    mPrefetchEncodedButton = (Button) view.findViewById(R.id.prefetch_encoded_now);
    mPrefetchEncodedButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPrefetchEncodedButton.setEnabled(false);
            final PrefetchSubscriber subscriber = new PrefetchSubscriber();
            for (Uri uri : mUris) {
              final DataSource<Void> ds =
                  Fresco.getImagePipeline().prefetchToEncodedCache(ImageRequest.fromUri(uri), null);
              ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
            }
          }
        });

    mPrefetchBitmapButton = (Button) view.findViewById(R.id.prefetch_bitmap_now);
    mPrefetchBitmapButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mPrefetchBitmapButton.setEnabled(false);
            final PrefetchSubscriber subscriber = new PrefetchSubscriber();
            for (Uri uri : mUris) {
              final DataSource<Void> ds =
                  Fresco.getImagePipeline().prefetchToBitmapCache(ImageRequest.fromUri(uri), null);
              ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
            }
          }
        });

    mImagesHolder = (ViewGroup) view.findViewById(R.id.images);
    Button toggleImages = (Button) view.findViewById(R.id.toggle_images);
    toggleImages.setOnClickListener(
        new View.OnClickListener() {
          private boolean mShowing = false;

          @Override
          public void onClick(View v) {
            if (!mShowing) {
              for (int i = 0; i < mImagesHolder.getChildCount(); i++) {
                ImageView imageView = (ImageView) mImagesHolder.getChildAt(i);
                VitoView.show(
                    mUris[i],
                    IMAGE_OPTIONS,
                    "ImagePipelinePrefetchFragment",
                    mImageOriginListener,
                    imageView);
              }
            } else {
              for (int i = 0; i < mImagesHolder.getChildCount(); i++) {
                VitoView.release(mImagesHolder.getChildAt(i));
              }
            }
            mShowing = !mShowing;
          }
        });
  }
Fragment that illustrates how to prefetch images to disk cache so that they load faster when
finally displayed.
samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/imagepipeline/ImagePipelinePrefetchFragment.java