本文整理汇总了Java中com.facebook.drawee.drawable.ScaleTypeDrawable类的典型用法代码示例。如果您正苦于以下问题:Java ScaleTypeDrawable类的具体用法?Java ScaleTypeDrawable怎么用?Java ScaleTypeDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScaleTypeDrawable类属于com.facebook.drawee.drawable包,在下文中一共展示了ScaleTypeDrawable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSetActualImageFocusPoint
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
@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);
}
示例2: testSetActualImageScaleType
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
@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());
}
示例3: maybeUpdateDebugOverlay
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
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();
}
}
}
示例4: maybeWrapWithScaleType
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
/**
* Wraps the given drawable with a new {@link ScaleTypeDrawable}.
*
* <p> If the provided drawable or scale type is null, the given drawable is returned without
* being wrapped.
*
* @return the wrapping scale type drawable, or the original drawable if the wrapping didn't
* take place
*/
@Nullable
static Drawable maybeWrapWithScaleType(
@Nullable Drawable drawable,
@Nullable ScaleType scaleType,
@Nullable PointF focusPoint) {
if (drawable == null || scaleType == null) {
return drawable;
}
ScaleTypeDrawable scaleTypeDrawable = new ScaleTypeDrawable(drawable, scaleType);
if (focusPoint != null) {
scaleTypeDrawable.setFocusPoint(focusPoint);
}
return scaleTypeDrawable;
}
示例5: wrapChildWithScaleType
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
/**
* 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;
}
示例6: getScaleTypeDrawableAtIndex
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
/**
* Gets the ScaleTypeDrawable at the specified index.
* In case there is no child at the specified index, a NullPointerException is thrown.
* In case there is a child, but the ScaleTypeDrawable does not exist,
* the child will be wrapped with a new ScaleTypeDrawable.
*/
private ScaleTypeDrawable getScaleTypeDrawableAtIndex(int index) {
DrawableParent parent = getParentDrawableAtIndex(index);
if (parent instanceof ScaleTypeDrawable) {
return (ScaleTypeDrawable) parent;
} else {
return WrappingUtils.wrapChildWithScaleType(parent, ScaleType.FIT_XY);
}
}
示例7: assertScaleTypeAndDrawable
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
private void assertScaleTypeAndDrawable(
Drawable expectedChild,
ScaleType expectedScaleType,
Drawable actualBranch) {
assertNotNull(actualBranch);
ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) actualBranch;
assertSame(expectedChild, scaleTypeDrawable.getCurrent());
assertSame(expectedScaleType, scaleTypeDrawable.getScaleType());
}
示例8: assertActualImageScaleType
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
private void assertActualImageScaleType(
ScaleType expectedScaleType,
PointF expectedFocusPoint,
Drawable actualBranch) {
assertNotNull(actualBranch);
ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) actualBranch;
assertSame(expectedScaleType, scaleTypeDrawable.getScaleType());
assertSame(ForwardingDrawable.class, scaleTypeDrawable.getCurrent().getClass());
AndroidGraphicsTestUtils.assertEquals(expectedFocusPoint, scaleTypeDrawable.getFocusPoint(), 0);
}
示例9: wrapWithScaleType
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
public static Drawable wrapWithScaleType(
Drawable drawable,
@Nullable ScalingUtils.ScaleType scaleType) {
Preconditions.checkNotNull(drawable);
if (scaleType == null) {
return drawable;
}
return new ScaleTypeDrawable(drawable, scaleType);
}
示例10: hasScaleTypeDrawableAtIndex
import com.facebook.drawee.drawable.ScaleTypeDrawable; //导入依赖的package包/类
/**
* Returns whether the given layer has a scale type drawable.
*/
private boolean hasScaleTypeDrawableAtIndex(int index) {
DrawableParent parent = getParentDrawableAtIndex(index);
return (parent instanceof ScaleTypeDrawable);
}