use of com.facebook.drawee.drawable.ScaleTypeDrawable in project fresco by facebook.
the class PipelineDraweeController method maybeUpdateDebugOverlay.
private void maybeUpdateDebugOverlay(@Nullable CloseableImage image) {
if (!mDrawDebugOverlay) {
return;
}
Drawable controllerOverlay = getControllerOverlay();
if (controllerOverlay == null) {
controllerOverlay = new DebugControllerOverlayDrawable();
setControllerOverlay(controllerOverlay);
}
if (controllerOverlay instanceof DebugControllerOverlayDrawable) {
DebugControllerOverlayDrawable debugOverlay = (DebugControllerOverlayDrawable) controllerOverlay;
debugOverlay.setControllerId(getId());
final DraweeHierarchy draweeHierarchy = getHierarchy();
ScaleType scaleType = null;
if (draweeHierarchy != null) {
final ScaleTypeDrawable scaleTypeDrawable = ScalingUtils.getActiveScaleTypeDrawable(draweeHierarchy.getTopLevelDrawable());
scaleType = scaleTypeDrawable != null ? scaleTypeDrawable.getScaleType() : null;
}
debugOverlay.setScaleType(scaleType);
if (image != null) {
debugOverlay.setDimensions(image.getWidth(), image.getHeight());
debugOverlay.setImageSize(image.getSizeInBytes());
} else {
debugOverlay.reset();
}
}
}
use of com.facebook.drawee.drawable.ScaleTypeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method assertScaleTypeAndDrawable.
private void assertScaleTypeAndDrawable(Drawable expectedChild, ScaleType expectedScaleType, Drawable actualBranch) {
assertNotNull(actualBranch);
ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) actualBranch;
assertSame(expectedChild, scaleTypeDrawable.getCurrent());
assertSame(expectedScaleType, scaleTypeDrawable.getScaleType());
}
use of com.facebook.drawee.drawable.ScaleTypeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testSetActualImageFocusPoint.
@Test
public void testSetActualImageFocusPoint() {
GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage).setProgressBarImage(mProgressBarImage).setActualImageScaleType(ScaleType.FOCUS_CROP).build();
// actual image index in DH tree
final int imageIndex = 2;
FadeDrawable fadeDrawable = (FadeDrawable) dh.getTopLevelDrawable().getCurrent();
ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) fadeDrawable.getDrawable(imageIndex);
assertNull(scaleTypeDrawable.getFocusPoint());
PointF focus1 = new PointF(0.3f, 0.4f);
dh.setActualImageFocusPoint(focus1);
AndroidGraphicsTestUtils.assertEquals(focus1, scaleTypeDrawable.getFocusPoint(), 0f);
PointF focus2 = new PointF(0.6f, 0.7f);
dh.setActualImageFocusPoint(focus2);
AndroidGraphicsTestUtils.assertEquals(focus2, scaleTypeDrawable.getFocusPoint(), 0f);
}
use of com.facebook.drawee.drawable.ScaleTypeDrawable in project fresco by facebook.
the class WrappingUtils method wrapChildWithScaleType.
/**
* Wraps the parent's child with a ScaleTypeDrawable.
*/
static ScaleTypeDrawable wrapChildWithScaleType(DrawableParent parent, ScaleType scaleType) {
Drawable child = parent.setDrawable(sEmptyDrawable);
child = maybeWrapWithScaleType(child, scaleType);
parent.setDrawable(child);
Preconditions.checkNotNull(child, "Parent has no child drawable!");
return (ScaleTypeDrawable) child;
}
use of com.facebook.drawee.drawable.ScaleTypeDrawable in project fresco by facebook.
the class GenericDraweeHierarchyTest method testSetActualImageScaleType.
@Test
public void testSetActualImageScaleType() {
GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage).build();
// actual image index in DH tree
final int imageIndex = 2;
FadeDrawable fadeDrawable = (FadeDrawable) dh.getTopLevelDrawable().getCurrent();
ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) fadeDrawable.getDrawable(imageIndex);
ScaleType scaleType1 = ScaleType.FOCUS_CROP;
dh.setActualImageScaleType(scaleType1);
assertEquals(scaleType1, scaleTypeDrawable.getScaleType());
ScaleType scaleType2 = ScaleType.CENTER;
dh.setActualImageScaleType(scaleType2);
assertEquals(scaleType2, scaleTypeDrawable.getScaleType());
}
Aggregations