@Override
  public boolean encode(
      @NonNull Resource<GifDrawable> resource, @NonNull File file, @NonNull Options options) {
    GifDrawable drawable = resource.get();
    Transformation<Bitmap> transformation = drawable.getFrameTransformation();
    boolean isTransformed = !(transformation instanceof UnitTransformation);
    if (isTransformed && options.get(ENCODE_TRANSFORMATION)) {
      return encodeTransformedToFile(drawable, file);
    } else {
      return writeDataDirect(drawable.getBuffer(), file);
    }
  }
@Test
  public void testEncode_WithEncodeTransformationFalse_whenOsThrows_returnsFalse()
      throws IOException {
    options.set(ReEncodingGifResourceEncoder.ENCODE_TRANSFORMATION, false);
    byte[] data = "testString".getBytes("UTF-8");
    when(gifDrawable.getBuffer()).thenReturn(ByteBuffer.wrap(data));

    assertThat(file.mkdirs()).isTrue();

    assertFalse(encoder.encode(resource, file, options));
  }