private void setAnimationUri(Uri uri) {

    final ImageDecodeOptionsBuilder optionsBuilder =
        ImageDecodeOptions.newBuilder().setMaxDimensionPx(4000);

    if (mGifDecoder != null) {
      optionsBuilder.setCustomImageDecoder(mGifDecoder);
    }
    final ImageOptions imageOptionsAutoPlay =
        ImageOptions.create().autoPlay(true).imageDecodeOptions(optionsBuilder.build()).build();
    final ImageOptions imageOptionsPaused =
        imageOptionsAutoPlay.extend().autoPlay(false).overlay(getPlayOverlayDrawable()).build();
    if (!mAutoPlayEnabled) {
      mImageView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (mIsPlaying) {
                VitoView.show(uri, imageOptionsPaused, CALLER_CONTEXT, mImageView);
              } else {
                VitoView.show(uri, imageOptionsAutoPlay, CALLER_CONTEXT, mImageView);
              }
              mIsPlaying = !mIsPlaying;
            }
          });
      VitoView.show(uri, imageOptionsPaused, CALLER_CONTEXT, mImageView);
    } else {
      VitoView.show(uri, imageOptionsAutoPlay, CALLER_CONTEXT, mImageView);
    }
  }
GIF example that illustrates how to display a simple GIF file
samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/imageformat/gif/ImageFormatGifFragment.java