use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeSpanSimpleTextFragment method updateText.
private void updateText() {
// The # will be replaced with the image.
String text = getString(R.string.drawee_span_simple_text);
int imagePosition = text.indexOf('#');
DraweeSpanStringBuilder draweeSpanStringBuilder = new DraweeSpanStringBuilder(text);
DraweeHierarchy draweeHierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources()).setPlaceholderImage(new ColorDrawable(Color.RED)).setActualImageScaleType(mScaleType).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setUri(mInlineImageUri).build();
draweeSpanStringBuilder.setImageSpan(getContext(), /* Context */
draweeHierarchy, /* hierarchy to be used */
controller, /* controller to be used to update the hierarchy */
imagePosition, /* image index within the text */
200, /* image width */
200, /* image height */
false, /* auto resize */
DraweeSpan.ALIGN_CENTER);
/* alignment */
int imagePosition2 = text.indexOf('@');
DraweeHierarchy draweeAnimatedHierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources()).setPlaceholderImage(new ColorDrawable(Color.RED)).setActualImageScaleType(mScaleType).build();
DraweeController animatedController = Fresco.newDraweeControllerBuilder().setUri(mInlineAnimatedImageUri).setAutoPlayAnimations(true).build();
draweeSpanStringBuilder.setImageSpan(getContext(), /* Context */
draweeAnimatedHierarchy, /* hierarchy to be used */
animatedController, /* controller to be used to update the hierarchy */
imagePosition2, /* image index within the text */
200, /* image width */
200, /* image height */
false, /* auto resize */
DraweeSpan.ALIGN_CENTER);
/* alignment */
mDraweeSpanTextView.setDraweeSpanStringBuilder(draweeSpanStringBuilder);
}
use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeMocks method mockGenericDraweeHierarchyBuilder.
/**
* Creates a mock GenericDraweeHierarchyBuilder that builds a new DH instance each time.
*
* @return mock GenericDraweeHierarchyBuilder
*/
public static GenericDraweeHierarchyBuilder mockGenericDraweeHierarchyBuilder() {
GenericDraweeHierarchyBuilder builder = mock(GenericDraweeHierarchyBuilder.class, CALLS_REAL_METHODS);
doAnswer(new Answer<Object>() {
@Override
public DraweeHierarchy answer(InvocationOnMock invocation) throws Throwable {
return mockDraweeHierarchy();
}
}).when(builder).build();
return builder;
}
use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeViewTest method testSetHierarchy.
@Test
public void testSetHierarchy() {
mDraweeView.setHierarchy(mDraweeHierarchy);
assertSame(mDraweeHierarchy, mDraweeView.getHierarchy());
assertSame(mTopLevelDrawable, mDraweeView.getDrawable());
DraweeHierarchy hierarchy2 = DraweeMocks.mockDraweeHierarchy();
mDraweeView.setHierarchy(hierarchy2);
assertSame(hierarchy2, mDraweeView.getHierarchy());
assertSame(hierarchy2.getTopLevelDrawable(), mDraweeView.getDrawable());
}
use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeViewTest method setUp.
@Before
public void setUp() {
Activity activity = Robolectric.buildActivity(Activity.class).create().get();
mDrawable = DrawableTestUtils.mockDrawable();
mTopLevelDrawable = DrawableTestUtils.mockDrawable();
mDraweeHierarchy = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable);
mController = DraweeMocks.mockController();
mDraweeView = new DraweeView<DraweeHierarchy>(activity);
}
use of com.facebook.drawee.interfaces.DraweeHierarchy in project fresco by facebook.
the class DraweeHolderTest method testSetNewHierarchyWithInvalidController.
@Test
public void testSetNewHierarchyWithInvalidController() {
final DraweeHierarchy draweeHierarchy2 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable);
final DraweeHolder draweeHolder2 = new DraweeHolder(draweeHierarchy2);
mDraweeHolder.setController(mController);
draweeHolder2.setController(mController);
final DraweeHierarchy draweeHierarchy3 = DraweeMocks.mockDraweeHierarchyOf(mTopLevelDrawable);
mDraweeHolder.setHierarchy(draweeHierarchy3);
assertEquals(draweeHierarchy2, mController.getHierarchy());
}
Aggregations