Tabnine Logo
UnitTransformation
Code IndexAdd Tabnine to your IDE (free)

How to use
UnitTransformation
in
com.bumptech.glide.load.resource

Best Java code snippets using com.bumptech.glide.load.resource.UnitTransformation (Showing top 9 results out of 315)

origin: bumptech/glide

@SuppressWarnings("unchecked")
<Z> Transformation<Z> getTransformation(Class<Z> resourceClass) {
 Transformation<Z> result = (Transformation<Z>) transformations.get(resourceClass);
 if (result == null) {
  for (Entry<Class<?>, Transformation<?>> entry : transformations.entrySet()) {
   if (entry.getKey().isAssignableFrom(resourceClass)) {
    result = (Transformation<Z>) entry.getValue();
    break;
   }
  }
 }
 if (result == null) {
  if (transformations.isEmpty() && isTransformationRequired) {
   throw new IllegalArgumentException(
     "Missing transformation for " + resourceClass + ". If you wish to"
       + " ignore unknown resource types, use the optional transformation methods.");
  } else {
   return UnitTransformation.get();
  }
 }
 return result;
}
origin: bumptech/glide

@Test
public void testReturnsGivenResource() {
 Resource<Object> resource = mockResource();
 UnitTransformation<Object> transformation = UnitTransformation.get();
 assertEquals(resource, transformation.transform(app, resource, 10, 10));
}
origin: bumptech/glide

@Test
public void testWritesBytesDirectlyToDiskIfTransformationIsUnitTransformation() {
 when(gifDrawable.getFrameTransformation()).thenReturn(UnitTransformation.<Bitmap>get());
 String expected = "expected";
 when(gifDrawable.getBuffer()).thenReturn(ByteBuffer.wrap(expected.getBytes()));
 encoder.encode(resource, file, options);
 assertThat(getEncodedData()).isEqualTo(expected);
 verify(gifEncoder, never()).start(any(OutputStream.class));
 verify(parser, never()).setData(any(byte[].class));
 verify(parser, never()).parseHeader();
}
origin: bumptech/glide

 @Test
 public void testEqualsHashCodeDigest() throws NoSuchAlgorithmException {
  @SuppressWarnings("unchecked") Transformation<Object> other = mock(Transformation.class);
  doAnswer(new Util.WriteDigest("other")).when(other)
    .updateDiskCacheKey(any(MessageDigest.class));

  keyTester
    .addEquivalenceGroup(
      UnitTransformation.get(),
      UnitTransformation.get())
    .addEquivalenceGroup(other)
    .addEmptyDigestRegressionTest(UnitTransformation.get())
    .test();
 }
}
origin: bumptech/glide

@Test
@SuppressWarnings("unchecked")
public void testSetsTransformationAsFrameTransformation() {
 Resource<GifDrawable> resource = mockResource();
 GifDrawable gifDrawable = mock(GifDrawable.class);
 Transformation<Bitmap> unitTransformation = UnitTransformation.get();
 when(gifDrawable.getFrameTransformation()).thenReturn(unitTransformation);
 when(gifDrawable.getIntrinsicWidth()).thenReturn(500);
 when(gifDrawable.getIntrinsicHeight()).thenReturn(500);
 when(resource.get()).thenReturn(gifDrawable);
 Bitmap firstFrame = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
 when(gifDrawable.getFirstFrame()).thenReturn(firstFrame);
 final int width = 123;
 final int height = 456;
 Bitmap expectedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
 Resource<Bitmap> expectedResource = mockResource();
 when(expectedResource.get()).thenReturn(expectedBitmap);
 when(wrapped.transform(any(Context.class), Util.<Bitmap>anyResource(), anyInt(), anyInt()))
   .thenReturn(expectedResource);
 transformation.transform(context, resource, width, height);
 verify(gifDrawable).setFrameTransformation(isA(Transformation.class), eq(expectedBitmap));
}
origin: bumptech/glide

@Nullable
private GifDrawableResource decode(
  ByteBuffer byteBuffer, int width, int height, GifHeaderParser parser, Options options) {
 long startTime = LogTime.getLogTime();
 try {
  final GifHeader header = parser.parseHeader();
  if (header.getNumFrames() <= 0 || header.getStatus() != GifDecoder.STATUS_OK) {
   // If we couldn't decode the GIF, we will end up with a frame count of 0.
   return null;
  }
  Bitmap.Config config = options.get(GifOptions.DECODE_FORMAT) == DecodeFormat.PREFER_RGB_565
    ? Bitmap.Config.RGB_565 : Bitmap.Config.ARGB_8888;
  int sampleSize = getSampleSize(header, width, height);
  GifDecoder gifDecoder = gifDecoderFactory.build(provider, header, byteBuffer, sampleSize);
  gifDecoder.setDefaultBitmapConfig(config);
  gifDecoder.advance();
  Bitmap firstFrame = gifDecoder.getNextFrame();
  if (firstFrame == null) {
   return null;
  }
  Transformation<Bitmap> unitTransformation = UnitTransformation.get();
  GifDrawable gifDrawable =
    new GifDrawable(context, gifDecoder, unitTransformation, width, height, firstFrame);
  return new GifDrawableResource(gifDrawable);
 } finally {
  if (Log.isLoggable(TAG, Log.VERBOSE)) {
   Log.v(TAG, "Decoded GIF from stream in " + LogTime.getElapsedMillis(startTime));
  }
 }
}
origin: guolindev/giffun

/**
 * Removes the current {@link Transformation}.
 *
 * @return This request builder.
 */
@SuppressWarnings("unchecked")
public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> dontTransform() {
  Transformation<ResourceType> transformation = UnitTransformation.get();
  return transform(transformation);
}
origin: guolindev/giffun

private GifDrawableResource decode(byte[] data, int width, int height, GifHeaderParser parser, GifDecoder decoder) {
  final GifHeader header = parser.parseHeader();
  if (header.getNumFrames() <= 0 || header.getStatus() != GifDecoder.STATUS_OK) {
    // If we couldn't decode the GIF, we will end up with a frame count of 0.
    return null;
  }
  Bitmap firstFrame = decodeFirstFrame(decoder, header, data);
  if (firstFrame == null) {
    return null;
  }
  Transformation<Bitmap> unitTransformation = UnitTransformation.get();
  GifDrawable gifDrawable = new GifDrawable(context, provider, bitmapPool, unitTransformation, width, height,
      header, data, firstFrame);
  return new GifDrawableResource(gifDrawable);
}
origin: mozilla-tw/Rocket

@SuppressWarnings("unchecked")
<Z> Transformation<Z> getTransformation(Class<Z> resourceClass) {
 Transformation<Z> result = (Transformation<Z>) transformations.get(resourceClass);
  if (result == null) {
  if (transformations.isEmpty() && isTransformationRequired) {
   throw new IllegalArgumentException(
     "Missing transformation for " + resourceClass + ". If you wish to"
       + " ignore unknown resource types, use the optional transformation methods.");
  } else {
   return UnitTransformation.get();
  }
 }
 return result;
}
com.bumptech.glide.load.resourceUnitTransformation

Javadoc

A no-op Transformation that simply returns the given resource.

Most used methods

  • get
    Returns a UnitTransformation for the given type.
  • transform

Popular in Java

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (Timer)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JFrame (javax.swing)
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now