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

    mSpinnerEntries =
        new Entry[] {
          new Entry(
              R.string.format_gif_label_small,
              sampleUris().createGifUri(ImageUriProvider.ImageSize.S)),
          new Entry(
              R.string.format_gif_label_medium,
              sampleUris().createGifUri(ImageUriProvider.ImageSize.M)),
          new Entry(
              R.string.format_gif_label_large,
              sampleUris().createGifUri(ImageUriProvider.ImageSize.L)),
        };

    mImageView = view.findViewById(R.id.image);

    final SwitchCompat switchBackground = view.findViewById(R.id.switch_background);
    switchBackground.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mImageView.setBackground(isChecked ? new CheckerBoardDrawable(getResources()) : null);
          }
        });
    final SwitchCompat switchAutoPlay = view.findViewById(R.id.switch_autoplay);
    switchAutoPlay.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mAutoPlayEnabled = isChecked;
            refreshAnimation();
          }
        });
    mAutoPlayEnabled = switchAutoPlay.isEnabled();

    final SwitchCompat switchAspect = view.findViewById(R.id.switch_aspect_ratio);
    switchAspect.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            ViewGroup.LayoutParams layoutParams = mImageView.getLayoutParams();
            layoutParams.height = layoutParams.width * (isChecked ? 2 : 1);
            mImageView.setLayoutParams(layoutParams);
          }
        });

    mSpinner = (Spinner) view.findViewById(R.id.spinner);
    mSpinner.setAdapter(new SimpleUriListAdapter());
    mSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            refreshAnimation();
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
    mSpinner.setSelection(0);

    final Spinner decoderSpinner = view.findViewById(R.id.spinner_select_decoder);
    decoderSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
              case 0:
                mGifDecoder = null;
                break;
              case 1:
                mGifDecoder = new GifDecoder();
                break;
              default:
                throw new IllegalArgumentException("Unknown decoder selected");
            }
            refreshAnimation();
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
    decoderSpinner.setSelection(0);
  }
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