Java Code Examples for android.text.style.ImageSpan#getDrawable()

The following examples show how to use android.text.style.ImageSpan#getDrawable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuntimesUtilsTest.java    From SuntimesWidget with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testCreateImageSpan()
{
    ImageSpan span1 = SuntimesUtils.createImageSpan(null);
    assertTrue("createImageSpan(null) must not return null!", span1 != null);

    ImageSpan span2 = SuntimesUtils.createImageSpan(mockContext, -1, warningSize, warningSize, warningColor);
    assertTrue("createImageSpan(context, invalidDrawableId, w, h, tint) must not return null!", span2 != null);

    ImageSpan span3 = SuntimesUtils.createImageSpan(mockContext, warningDrawableID, warningSize, warningSize, warningColor);
    assertTrue("createImageSpan(context, validDrawableId, w, h, tint) must not return null!", span3 != null);

    Drawable drawable3 = span3.getDrawable();
    assertTrue("drawable must not be null", drawable3 != null);
    assertTrue("createImageSpan(context, drawableID, w, h, tint) should set width to w!", drawable3.getBounds().width() == warningSize);
    assertTrue("createImageSpan(context, drawableID, w, h, tint) should set height to h!", drawable3.getBounds().height() == warningSize);

    ImageSpan span4 = SuntimesUtils.createImageSpan(span3);
    assertTrue("createImageSpan(ImageSpan) should create a new object!", span4 != span3);
    assertTrue("createImageSpan(ImageSpan) should have the same drawable!", span4.getDrawable().equals(span3.getDrawable()));
}
 
Example 2
Source File: SuntimesUtils.java    From SuntimesWidget with GNU General Public License v3.0 5 votes vote down vote up
public static ImageSpan createImageSpan(ImageSpan other)
{
    Drawable drawable = null;
    if (other != null)
        drawable = other.getDrawable();

    return new ImageSpan(drawable);
}