Search in sources :

Example 91 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class ApduServiceInfo method loadBanner.

public Drawable loadBanner(PackageManager pm) {
    Resources res;
    try {
        res = pm.getResourcesForApplication(mService.serviceInfo.packageName);
        Drawable banner = res.getDrawable(mBannerResourceId);
        return banner;
    } catch (NotFoundException e) {
        Log.e(TAG, "Could not load banner.");
        return null;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "Could not load banner.");
        return null;
    }
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Drawable(android.graphics.drawable.Drawable) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) NotFoundException(android.content.res.Resources.NotFoundException) Resources(android.content.res.Resources)

Example 92 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class ChangeImageTransform method createAnimator.

/**
     * Creates an Animator for ImageViews moving, changing dimensions, and/or changing
     * {@link android.widget.ImageView.ScaleType}.
     *
     * @param sceneRoot   The root of the transition hierarchy.
     * @param startValues The values for a specific target in the start scene.
     * @param endValues   The values for the target in the end scene.
     * @return An Animator to move an ImageView or null if the View is not an ImageView,
     * the Drawable changed, the View is not VISIBLE, or there was no change.
     */
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    Rect startBounds = (Rect) startValues.values.get(PROPNAME_BOUNDS);
    Rect endBounds = (Rect) endValues.values.get(PROPNAME_BOUNDS);
    if (startBounds == null || endBounds == null) {
        return null;
    }
    Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
    Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);
    boolean matricesEqual = (startMatrix == null && endMatrix == null) || (startMatrix != null && startMatrix.equals(endMatrix));
    if (startBounds.equals(endBounds) && matricesEqual) {
        return null;
    }
    ImageView imageView = (ImageView) endValues.view;
    Drawable drawable = imageView.getDrawable();
    int drawableWidth = drawable.getIntrinsicWidth();
    int drawableHeight = drawable.getIntrinsicHeight();
    ObjectAnimator animator;
    if (drawableWidth == 0 || drawableHeight == 0) {
        animator = createNullAnimator(imageView);
    } else {
        if (startMatrix == null) {
            startMatrix = Matrix.IDENTITY_MATRIX;
        }
        if (endMatrix == null) {
            endMatrix = Matrix.IDENTITY_MATRIX;
        }
        ANIMATED_TRANSFORM_PROPERTY.set(imageView, startMatrix);
        animator = createMatrixAnimator(imageView, startMatrix, endMatrix);
    }
    return animator;
}
Also used : Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) ObjectAnimator(android.animation.ObjectAnimator) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView)

Example 93 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class DynamicDrawableSpan method getSize.

@Override
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
    Drawable d = getCachedDrawable();
    Rect rect = d.getBounds();
    if (fm != null) {
        fm.ascent = -rect.bottom;
        fm.descent = 0;
        fm.top = fm.ascent;
        fm.bottom = 0;
    }
    return rect.right;
}
Also used : Rect(android.graphics.Rect) Drawable(android.graphics.drawable.Drawable)

Example 94 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class DynamicDrawableSpan method draw.

@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
    Drawable b = getCachedDrawable();
    canvas.save();
    int transY = bottom - b.getBounds().bottom;
    if (mVerticalAlignment == ALIGN_BASELINE) {
        transY -= paint.getFontMetricsInt().descent;
    }
    canvas.translate(x, transY);
    b.draw(canvas);
    canvas.restore();
}
Also used : Drawable(android.graphics.drawable.Drawable) Paint(android.graphics.Paint)

Example 95 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class ExpandableListView method drawDivider.

@Override
void drawDivider(Canvas canvas, Rect bounds, int childIndex) {
    int flatListPosition = childIndex + mFirstPosition;
    // all items, then the item below it has to be a group)
    if (flatListPosition >= 0) {
        final int adjustedPosition = getFlatPositionForConnector(flatListPosition);
        PositionMetadata pos = mConnector.getUnflattenedPos(adjustedPosition);
        // If this item is a child, or it is a non-empty group that is expanded
        if ((pos.position.type == ExpandableListPosition.CHILD) || (pos.isExpanded() && pos.groupMetadata.lastChildFlPos != pos.groupMetadata.flPos)) {
            // These are the cases where we draw the child divider
            final Drawable divider = mChildDivider;
            divider.setBounds(bounds);
            divider.draw(canvas);
            pos.recycle();
            return;
        }
        pos.recycle();
    }
    // Otherwise draw the default divider
    super.drawDivider(canvas, bounds, flatListPosition);
}
Also used : PositionMetadata(android.widget.ExpandableListConnector.PositionMetadata) Drawable(android.graphics.drawable.Drawable)

Aggregations

Drawable (android.graphics.drawable.Drawable)2742 BitmapDrawable (android.graphics.drawable.BitmapDrawable)527 View (android.view.View)316 ColorDrawable (android.graphics.drawable.ColorDrawable)283 Bitmap (android.graphics.Bitmap)244 ImageView (android.widget.ImageView)232 TextView (android.widget.TextView)220 Paint (android.graphics.Paint)213 LayerDrawable (android.graphics.drawable.LayerDrawable)212 Rect (android.graphics.Rect)204 StateListDrawable (android.graphics.drawable.StateListDrawable)152 Resources (android.content.res.Resources)143 AnimationDrawable (android.graphics.drawable.AnimationDrawable)137 PackageManager (android.content.pm.PackageManager)127 Context (android.content.Context)126 TypedArray (android.content.res.TypedArray)115 ClipDrawable (android.graphics.drawable.ClipDrawable)108 ViewGroup (android.view.ViewGroup)100 Test (org.junit.Test)100 ShapeDrawable (android.graphics.drawable.ShapeDrawable)94